gpt4 book ai didi

android - 如何将 Android Button View 保持在屏幕底部?

转载 作者:行者123 更新时间:2023-11-29 00:11:54 25 4
gpt4 key购买 nike

我有一个主要包含 2 个组件的 Activity : ScrollView 和按钮。我想将按钮固定在屏幕底部。

我尝试了很多东西,但我无法将按钮位置固定在屏幕按钮上,因为随着 ScrollView 内容的增加,按钮被推到了 Activity 屏幕之外。

我想实现这样的目标: enter image description here

谁能告诉我如何实现这个目标?

我的 XML 文件是干净的(所有自定义 View 都是以编程方式编写的,无法共享!):

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView"
android:layout_gravity="center_horizontal">

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/editableViewGroup"></LinearLayout>

</ScrollView>

<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Save Changes"
android:id="@+id/customButton" />

最佳答案

使用LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true">

<!-- ... -->

</ScrollView>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save Changes"/>

</LinearLayout>

关于android - 如何将 Android Button View 保持在屏幕底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29634007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com