【发布时间】:2016-11-23 15:02:01
【问题描述】:
在下面的布局文件中,我创建了一个滚动视图,它包含一个 tableLayout。表格布局中的第一行是一个 Edittext。尽管我设置了 Edittext 视图参数 如下:
android:layout_width="match_parent"
android:layout_height="wrap_content"
它永远不会从左到右跨越屏幕!!
请告诉我如何让 Edittext 从左到右跨越屏幕?
布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<!-- scrollView can host only one direct parent-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableLayout
android:id="@+id/tl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
android:id="@+id/tr0"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et0"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:id="@+id/tr1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_label_x1"
android:layout_weight="1">
<TextView
android:id="@+id/tv_label_x1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="x1: "/>
<TextView
android:id="@+id/tv_x1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/tv_label_x1"
android:text="x1value" />
</RelativeLayout>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
【问题讨论】:
标签: android layout android-edittext tablelayout android-tablelayout