【发布时间】:2015-08-30 23:09:12
【问题描述】:
我正在尝试创建一个带有 EditText 和关联标签的视图。我将它们放在 GridLayout 中。 EditText 位于最后一列,文本似乎超出了屏幕范围。
<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"
tools:context="mobi.designmyapp.osmtemplate.note.NoteActivity"
android:orientation="vertical">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:rowCount="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="@+id/comment_edit_text"
android:text="@string/comment_label"
android:padding="8dp"
android:textColor="@color/background_material_dark"
android:maxLines="5"
/>
<EditText
android:id="@+id/comment_edit_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/comment_text_hint"/>
</GridLayout>
【问题讨论】:
-
您是否尝试过将孩子的宽度/高度更改为
match_parent? -
是的,它给出了相同的结果。
-
我这边看起来还不错。网格布局是另一个视图的子视图吗?例如:
RelativeLayout -
它在线性布局中,编辑文本似乎超出了我的标签大小的屏幕。
-
好的,我知道了。看我的回答。
标签: android android-gridlayout