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

84
April 26, 2022, at 07:00 AM

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? Thanks! Cheers!

Answer 1

Android framework doesn't have such option built-in, you could write it by own, but Google did that for you. check out flexbox-layout library

Rent Charter Buses Company
READ ALSO
how to use tap method instead of click method in appium?

how to use tap method instead of click method in appium?

I'm trying to automate an android test in appium and I have selected the webdriver as in wd/hub for this purposeHowever, the tap method there is virtually the click method as all the auto-recorded steps are generated as clicks instead of tap / touch

90
Does assetlinks.json file for Android App Links have a size limit like the iOS counterpart?

Does assetlinks.json file for Android App Links have a size limit like the iOS counterpart?

In order to only allow authorized apps to open https links, Android has App Links, and iOS has Universal LinksIn both, one needs to upload a file, viz

95
gradle: Duplicate value for resources coming from multiple external libraries

gradle: Duplicate value for resources coming from multiple external libraries

I have a situation where I am trying to add two dependencies that have resources conflict

119
Caused by android.app.ForegroundServiceStartNotAllowedException startForegroundService() not allowed due to mAllowStartForeground false

Caused by android.app.ForegroundServiceStartNotAllowedException startForegroundService() not allowed due to mAllowStartForeground false

I have upgrade the Android SDK project 30 to 31Also i am using the the Android Beacon Library for scanning the the iBeacon

194