Hello!

Help to choose the right markup for displaying two pictures so that they are displayed

  • in portrait orientation: the first from the top, the second from the bottom;

  • in horizontal orientation: first left, second right; Pictures should stick to each other in the center. What Layot and what ratio of fill_ parent, match_ parent, wrap_content to choose for each ImageView?

It seems like a simple question, but got lost in three pines.

Markup Code:

<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/fon" tools:ignore="UseCompoundDrawables" > <ImageView android:id="@+id/aboutImageOne" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="top|center_vertical|center_horizontal" android:contentDescription="@string/about_image" /> <ImageView android:id="@+id/aboutImageTwo" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_vertical|center_horizontal" android:contentDescription="@string/about_image" /> </GridLayout> 

    1 answer 1

    What prevents you from creating 2 different layout for portrait and landscape mode? No wonder Google invented the layout-land , layout-port resource folders.
    The ratio of fill_ parent , match_ parent , wrap_content choose on the basis of what scale to display images (take max. Area, stretch, original size ...).
    And what would they stick in the center to each other is enough to choose a linear layout , and put him gravity in the center .

    • Yes everything is correct! This is me yesterday protupil. Recycled. I repent. Vertical. Horizontal Plus, every picture in your layout and center it there. It’s just that in the manifesto I for each activist banned its re-creation — that’s where all the nonsense came from. Thank! - fundator