【发布时间】:2017-01-05 10:24:31
【问题描述】:
我有一个简单的GridLayout:
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2"
android:rowCount="1" >
<TextView
android:layout_column="0"
android:layout_row="0"
android:text="Label"/>
<EditText
android:inputType="text"
android:layout_column="1"
android:layout_row="0"
android:text="asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf asdf"
android:layout_gravity="fill_horizontal"/>
</GridLayout>
但是,这会导致EditText 延伸到屏幕外,如下所示(图片来自 IDE,但在设备上运行时效果相同)。
看起来EditText 实际上是屏幕的整个宽度,而不是GridLayout 单元格的宽度,这就是它离开屏幕的原因。布局中有什么问题导致了这种情况?
【问题讨论】:
标签: android grid-layout android-gridlayout