【发布时间】:2014-11-02 20:12:10
【问题描述】:
在我的 xml 文件中,我有一个线性布局和一个按钮。 linearLayout 包含很多 textView 和复选框。所以我希望这些 textViews 和复选框能够滚动,但按钮应该保留在其位置,即它不应该与 textViews 一起滚动。为此,我用这样的滚动视图覆盖我的线性布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/homeo11" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/nexttodetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
</LinearLayout>
</ScrollView>>
<Button android:id="@+id/Next4"
android:layout_gravity="right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Next" />
</LinearLayout>
但是这样做,隐藏了我的按钮。意味着文本视图和复选框现在可以正确滚动,但我看不到我的下一个按钮。我尝试将 scrollView 布局:从 fill_parent 替换为 wrap_content 的高度,但这也不起作用。有什么帮助吗?
【问题讨论】:
-
在滚动条和按钮中使用
android:layout_weight="1" -
如果您改用
RelativeLayout作为最外层布局,您可以在按钮内使用android:layout_alignParentBottom="true"将其保持在底部并始终可见。
标签: android android-layout scrollview