简体   繁体   English

Android - 让所有的 RelativeLayouts 像向左浮动并自动换行

[英]Android - make all RelativeLayouts like floating left and going automatically in new lines

I have this scenario :我有这种情况:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
.... >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        
        <ImageView as label ... />
        
        <TextView text content.... 
          android:layout_toRightOf=label />
        
    </RelativeLayout>
    
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        
        <ImageView as label ... />
        
        <TextView text content.... 
          android:layout_toRightOf=label />
        
    </RelativeLayout>   
    
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        
        <ImageView as label ... />
        
        <TextView text content.... 
          android:layout_toRightOf=label />
        
    </RelativeLayout>   

    .
    .
    .
    .
    
</LinearLayout>

And I wanted all those relativelayouts to position automatically each one next to the previous and going automatically at new line if mobile phone is vertical and going automatically in one line if mobile phone is horizontal... I tried with GridLayout but looks like is not so good because contents textviews have different lenght depends from informations I get... is there a way to solve that?而且我希望所有这些相对布局自动定位到上一个旁边,如果手机是垂直的,则自动换行,如果手机是水平的,则自动换行...我尝试使用 GridLayout,但看起来并非如此很好,因为内容文本视图有不同的长度取决于我得到的信息......有没有办法解决这个问题? Thanks!谢谢! Cheers!干杯!

Android framework doesn't have such option built-in, you could write it by own, but Google did that for you. Android框架没有内置这样的选项,你可以自己写,但谷歌为你做了。 check out flexbox-layout library查看flexbox-layout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用RelativeLayouts的onclick在Android上的视图出现问题 - Trouble in views on android with onclick at RelativeLayouts 如何在Android中制作一个像这样的径向浮动动作按钮? - How to make a radial floating action button like this in android? Android:自动为xml中的所有ID创建变量 - Android: automatically make variables for all IDs in xml Android-如何使edittext中的所有行都加下划线? - Android - How to make all lines in an edittext underlined? 如何在Android中以编程方式创建Hierarchical RelativeLayouts? - How to create Hierarchical RelativeLayouts programmatically in android? 无法为Android创建RelativeLayouts的ListView - Can't create ListView of RelativeLayouts for Android Linear和RelativeLayouts的Android XML对齐问题。 - Android XML alignment issue with Linear and RelativeLayouts. Android-制作一个loggfile并在每个“事件”的新行中显示为TextView? - Android - make a loggfile and display as a TextView in WITH new lines for every “events”? 如何在Android中自动折叠浮动动作按钮 - How to collapse floating action button automatically in android 从左向右滑动Android浮动菜单 - Android floating menu on left to right swipe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM