Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(android)当屏幕宽度已满时,如何将图像继续放在下一行?_Android_Android Layout_Android Imagebutton - Fatal编程技术网

(android)当屏幕宽度已满时,如何将图像继续放在下一行?

(android)当屏幕宽度已满时,如何将图像继续放在下一行?,android,android-layout,android-imagebutton,Android,Android Layout,Android Imagebutton,嗯……也许这很简单,但我找不到一个如何做到这一点的示例 我需要显示一组imagesbuttons(大约10个),我希望使用可用宽度在另一个按钮的右侧显示一次,当并没有更多空间时,继续在下面的空间中显示。(preety simple在html中购买我在android中快疯了) 最初的想法是图片和下面的文本视图作为标题,后来我发现这对我最基本的Android来说太多了,所以我决定,只使用图片按钮 把一个固定的数量作为一个参数,并调整图像大小以适应屏幕分布,这是非常可爱的…这对我来说现在也太多了 我考

嗯……也许这很简单,但我找不到一个如何做到这一点的示例

我需要显示一组imagesbuttons(大约10个),我希望使用可用宽度在另一个按钮的右侧显示一次,当并没有更多空间时,继续在下面的空间中显示。(preety simple在html中购买我在android中快疯了)

最初的想法是图片和下面的文本视图作为标题,后来我发现这对我最基本的Android来说太多了,所以我决定,只使用图片按钮

把一个固定的数量作为一个参数,并调整图像大小以适应屏幕分布,这是非常可爱的…这对我来说现在也太多了

我考虑到了这两个方面的想法…相对的假设,当没有更多的空间可用时,它会继续在下面…我不能

如直线水平布置……我不能:(

我应该从代码中而不是从布局中这样做吗

这是我的实际屏幕:

理想:

这是我的基本代码:

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


    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageButton1"
        android:src="@drawable/btn_fra_pierre"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"/>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageButton2"
        android:src="@drawable/btn_sab_evo"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imageButton1"/>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageButton3"
        android:src="@drawable/btn_fra_pierre"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imageButton2"/>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageButton4"
        android:src="@drawable/btn_sab_evo"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/imageButton3"/>



</RelativeLayout>


非常感谢!

您正在尝试的是所谓的FlowLayout。它在标准android SDK中不可用。您可能需要为此编写自己的自定义布局。我建议查看一些第三方库,例如Google的flexbox布局有点新:

我建议使用a
tablelayout
我建议使用RecyclerView(示例:)我想这正是我需要的:D谢谢!谢谢。我目前正在使用这个