我有一个带有 textview 和 edittext 的相对布局。 edittext 在同一行与 textview 的左(或右)对齐。
如何让edittext延伸到屏幕的最边缘(使用xml)。 设置宽度不合适,因为我可能有不同的分辨率。
最佳答案
如果你想使用 TableLayout,你可以使用下面的代码。也可以使用 TableLayout。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:stretchColumns="*"
android:shrinkColumns="*">
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp" >
<TextView
android:id="@+id/textView"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Username"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/editText"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="5"
android:hint="Password"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
</LinearLayout>
关于android - 扩展 Android edittext 扩展到屏幕边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47007119/