gpt4 book ai didi

Android ScrollView 和屏幕底部的按钮

转载 作者:IT王子 更新时间:2023-10-29 00:10:36 25 4
gpt4 key购买 nike

我想实现这个:一个包含许多元素(ImageViews、TextViews、EditTexts 等)的 ScrollView,然后在 ScrollView 之后,一些按钮(它们是自定义 ImageViews)总是恰好出现在屏幕底部。

如果我使用 android:fillViewport="true"属性,那么如果 ScrollView 的元素太大而无法适应屏幕尺寸,按钮就会变得不可见。如果我使用 android:Weight=1 属性,那么当屏幕很大并且可以容纳时,ScrollView 只能获得屏幕的 50%(我希望按钮占一小部分,大约 10%)。如果我将 android:Weight 设置为更大的值,那么按钮会显得非常小。

请帮忙!也许这是我忽略的简单事情,但我已经敲了几个小时的头!

最佳答案

刚刚创建并测试了它。看起来像你想要的。

<?xml version="1.0" encoding="utf-8"?>

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

<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_alignParentBottom="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Button1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Custom Button2"/>
</LinearLayout>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/buttons">
<!--Scrollable content here-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="test text"
android:textSize="40dp"/>
</LinearLayout>
</ScrollView>

</RelativeLayout>

关于Android ScrollView 和屏幕底部的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9326299/

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