【发布时间】:2016-06-04 15:40:40
【问题描述】:
我的意图是通过将TextView 嵌套在ScrollView 中来使我的TextView 可滚动(尽管我知道TextView 可以自行滚动(不需要父ScrollView),我想做以这种方式 :) ) 并让 ScrollView 填满屏幕的整个宽度。
以下代码中的布局有效,但ScrollView 没有填满屏幕的整个宽度。但是,它的父 TableRow 填充了整个宽度。
我尝试将ScrollView 的android:layout_width 的值替换为fill_parent、match_parent 和wrap_content,但它们都没有完全填充宽度。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_my">
<TableRow>
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message"
android:layout_weight="1"/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/button_send"
android:onClick="sendMessage"/>
</TableRow>
<TableRow>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">
<TextView
android:id="@+id/message_box"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</ScrollView>
</TableRow>
</TableLayout>
【问题讨论】:
标签: android android-layout android-scrollview android-tablelayout