我希望在我的活动屏幕底部保留一个按钮。无论上面的scrollview大小如何,它都必须被固定。问题是,一旦scrollview的文本浏览占据了一定的位置,我的按钮的高度就会不断下降,最终会被移出活动屏幕。这是我使用的布局。在屏幕底部始终放置一个固定高度的按钮
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:id="@+id/tvBanner" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" android:gravity="center"
android:text="Practice Exam" />
<ScrollView android:id="@+id/Scroll" android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:id="@+id/LinearLayout1"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/tvDesc" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_margin="10dp"
android:gravity="center" android:paddingTop="40dp" android:text="@string/welcom"
android:textSize="20sp" />
<TextView android:id="@+id/tvURL" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_marginBottom="30dp"
android:paddingTop="10dp" android:layout_gravity="center"
android:text="hello" android:textColor="@android:color/white"
android:typeface="sans" />
</LinearLayout>
</ScrollView>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="bottom">
<Button android:id="@+id/btBottom" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:text="Enter" />
</RelativeLayout>
</LinearLayout>
我也尝试在滚动视图中使用android:weight = 1和android:layout_height = 0dp。但是这从我的活动中移除了整个滚动视图部分,我什么也看不见。
我知道,有很多类似的问题询问了这个,并相信我,我尝试了很多这些。但是,这些技巧都没有为我工作。我花了将近半天的时间来解决这个问题。请帮助。
这似乎是工作..谢谢一吨! – ambit 2012-03-07 14:25:15