android - 如何将 View 粘贴在屏幕底部以便上面的部分可以移动?

标签 android android-layout

我的布局由一个包含所有内容的ScrollView组成。在某些时候,我需要在屏幕底部 ScrollView 顶部(上方)显示一个 View (因此 ScrollView 位于 View),这样我就可以上下滚动屏幕,同时此 View 仍然粘在设备的屏幕底部。请建议大家如何进行这样的布局。谢谢。

最佳答案

如果您希望 ScrollView 位于 View 后面,可以这样做:

(部分代码复制自 this SO问题)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:id="@+id/RelativeLayout1">

        <ScrollView android:id="@+id/scrollView"  
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </ScrollView>

        <View android:id="@+id/bottomView" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_alignParentBottom="true"
            android:visibility="gone">>
        </View>
</RelativeLayout>

ScrollView 现在将扩展到 View 元素之外。

关于android - 如何将 View 粘贴在屏幕底部以便上面的部分可以移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13628866/

相关文章:

android - AppBarLayout 高度更改在 appCompat v24.0.0 上延迟

Android - 如何将对象序列化和反序列化到公共(public)外部存储或从公共(public)外部存储中反序列化对象?

java - Android:当父级聚焦时更改 TextView textColor

android - 为什么 RecyclerView 项目中的 ConstraintLayout 比 LinearLayout 慢?

android - 如何在 Android Studio 的 EditText 中设置默认值

java - android 新手 - 使用 'ant' 编译有什么好处?

android - 运行 Android Lint 遇到了...失败。 java.lang.NullPointerException异常

java - Android Activity 方法使显示屏闪烁白色以发出警告通知

java - 如何以编程方式将 ScrollView 滚动到底部

java - 自定义 setMessage 对话框 TextView 无法转换为 java.lang.CharSequence