Scaling and aligning the relative structure of Android

I need to create an Andorid layout which is shown below, however I cannot handle positioning correctly.

enter image description here

Here are the views of the parts of the view and my limitations:

  • A: Image, fixed width, hold height, left alignment
  • B: Text view, auto scaled width, hold height
  • C: text view, auto scaled width, commit height
  • D: text view, auto scaled width, commit height
  • E: text view, auto scaled width, hold height
  • F: Image, Fixed Width, Fix Height, Right Alignment

I tried the relative layout, but I can't handle the right view (i.e. F). So what should be the proper XML markup for this layout?

+4
source share
2 answers

Pretty simple. Try something like this (I left other things like height and width to save space):

<RelativeLayout> <ImageView android:id="@+id/A" android:layout_alignParentLeft="true" /> <ImageView android:id="@+id/F" android:layout_alignParentRight="true" /> <LinearLayout android:id="@+id/container" android:layout_toRightOf="@+id/A" android:layout_toLeftOf="@+id/F" android:orientation="horizontal" android:weightSum="3" > <TextView android:id="@+id/B" android:layout_weight="1" /> <TextView android:id="@+id/C" android:layout_weight="1" /> <TextView android:id="@+id/D" android:layout_weight="1" /> </LinearLayout> <TextView android:id="@+id/E" android:layout_toRightOf="@+id/A" android:layout_toLeftOf="@+id/F" android:layout_below="@+id/container" /> </RelativeLayout> 
+7
source

Posting some code that you tried will help us understand what you have tried so far. But why doesn't the relative layout work for you? Have you tried something like

 <ImageView android:id="@+id/imageViewF" android:layout_alightParentRight="true" /> 

Try reading Relative Layout if you don't already have

0
source

Source: https://habr.com/ru/post/1395284/


All Articles