【发布时间】:2013-05-01 11:35:21
【问题描述】:
在我的活动中,我有 2 个文本视图。我需要拉伸 textview2 的高度以填充屏幕。我的文本视图在以滚动视图为根的相对布局内。即使我提到了 match_parent 它也不是填充屏幕而是作为 wrap_content。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true"
android:id="@+id/scrollView1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="20dp"
tools:context=".CoupansActivity"
android:background="@drawable/back_ground">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:textSize="20dp"
android:text="COUPONS" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill"
android:layout_centerHorizontal="true"
android:layout_marginTop="23dp"
android:background="@drawable/back"
android:gravity="center"
android:text="Some text" />
</RelativeLayout>
</ScrollView>
【问题讨论】:
-
fill_parent 呢?应该做的工作。
-
@sandkasten
fill_parent自 API 8 起已弃用,取而代之的是match_parent。 -
哦,我上次创建的应用程序都是针对 API 7 的,所以不知道这个变化^^
-
我需要横向模式下的滚动视图才能看到文本视图中的全部内容。所以请使用滚动视图将答案发送给我。
-
那么现在怎么样了,...
标签: android textview scrollview android-relativelayout