我在一个滚动视图中有一个相对论.

有没有办法拥有真正的Fill_Parent/Match_Parent行为?

我的布局:

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

    <ImageView
    android:id="@+id/top"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:scaleType="fitXY"
    android:src="@drawable/top" />

    <ImageView
    android:id="@+id/header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/top"
    android:scaleType="fitXY"
    android:src="@drawable/headerbig" />

    <ImageView
    android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/header"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="3dp"
    android:src="@drawable/logo" />

    <ScrollView
    android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom"
    android:layout_below="@+id/logo"
    android:background="@drawable/background" >

        <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

             <ImageView
            android:id="@+id/dashboard01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/dashboard02"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="30dp"
            android:src="@drawable/dashboard01"
            android:visibility="visible" />

            <ImageView
            android:id="@+id/dashboard02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10dp"
            android:src="@drawable/dashboard02" />

             <ImageView
            android:id="@+id/dashboard03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/dashboard02"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="40dp"
            android:src="@drawable/dashboard03"
            android:visibility="visible" />
         </RelativeLayout>
    </ScrollView>

    <ImageView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/logo"
    android:layout_centerHorizontal="true"
    android:scaleType="fitXY"
    android:src="@drawable/bar" />

    <ImageView
    android:id="@+id/bottom"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:scaleType="fitXY"
    android:src="@drawable/bottom" />

</RelativeLayout>

推荐答案

try 将android:fillViewport="true"添加到您的ScrollView

请记住,android:layout_height=”fill_parent”的意思是"将高度设置为父对象的高度".这显然不是你在使用ScrollView的时候想要的.毕竟,如果ScrollView的内容总是和它本身一样高,它就会变得毫无用处.要解决此问题,需要使用名为android:fillViewport的ScrollView属性.当设置为true时,如果需要,此属性会使滚动视图的子级展开到ScrollView的高度.当子对象比ScrollView高时,该属性不起作用.

http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/

Android相关问答推荐

如何将子零部件的大小调整为可以调整大小的父组件大小?

有人能帮我在应用程序上使用模拟位置时避免被发现吗?我已经反编译并粘贴了一个代码,S小文件

Android布局渲染问题

当按下通知时,将Android应用程序置于前台

如何判断堆肥是否为空?

如何检测低性能 Android 设备进行条件动画渲染?

当我想使用例如 material3 时,为什么我需要添加对 material 的依赖?底部导航?

如何避免多次调用 Jetpack Compose 的 onClick 回调

为什么我收到这个错误我需要安装 android studio

在 MVVM Jetpack Compose 上添加依赖项时出现重复类错误

如何在一个活动中预加载图像然后在另一个活动中加载它们?

从 Jetpack Compose 中的 IconButton 中删除黑色色调

如何将可重用的 ExtendedFloatingActionButton 与可重用的脚手架链接起来

在 Compose 中停止键盘将顶部应用栏推离屏幕

我该怎么做文本计时器

如何使用 Jetpack Compose 制作两个圆圈

无法使用 Gradle 托管设备对基线配置文件运行测试

新安装 Expo Go 的 android 设备上的 sdk 46.0.0 (@snack/sdk.46.0.0) 出错

Google Play 控制台您的应用是否使用广告 ID?

在jetpack compose中看不到圆角