gpt4 book ai didi

具有 RelativeLayout 的 Android ScrollView 不起作用

转载 作者:行者123 更新时间:2023-11-30 02:53:52 24 4
gpt4 key购买 nike

我的 Android 项目有问题。

我创建了一个包含图像列表的 View ,在 Nexus 5 屏幕上我可以看到所有这些图像,但在最小的手机上,其中一些图像是重叠的。

所以我决定插入一个 ScrollView,但我看到了很多错误。

我发现了很多类似的问题,但对我没有任何帮助。

有人可以帮助我吗?

如果没有 ScrollView,这是可以正常工作的代码:

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

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="none" >

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0088ff"
android:clickable="false">



<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/imageView"
android:src="@drawable/icona_pr"
android:layout_marginLeft="28dp"
android:contentDescription="@string/icona_pr"
android:onClick="apriPreliminare"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:id="@+id/imageView2"
android:src="@drawable/icona_p"
android:contentDescription="@string/icona_p"
android:onClick="apriPesantezza"
android:layout_above="@+id/imageView3"
android:layout_alignLeft="@+id/imageView"
android:layout_alignStart="@+id/imageView" />

[...]
</RelativeLayout>
</ScrollView>

当我在 Android Studio 中选择“设计”选项卡查看预览时,我看到了一个更长的屏幕。在 Nexus 5 上它似乎工作正常,没有任何变化,但在 Galaxy S2 上前 2 个 ImageView 重叠。

最佳答案

这是你的布局

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:scrollbars="none" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:orientation="vertical" >

<ImageView
android:id="@+id/imageView"
android:layout_width="70dp"
android:layout_height="70dp" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="70dp"
android:layout_height="70dp" />

<ImageView
android:id="@+id/imageView3"
android:layout_width="70dp"
android:layout_height="70dp" />

<ImageView
android:id="@+id/imageView4"
android:layout_width="70dp"
android:layout_height="70dp" />

<ImageView
android:id="@+id/imageView5"
android:layout_width="70dp"
android:layout_height="70dp" />

<ImageView
android:id="@+id/imageView6"
android:layout_width="70dp"
android:layout_height="70dp" />
</LinearLayout>

</ScrollView>

关于具有 RelativeLayout 的 Android ScrollView 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23664609/

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