Hello. There is the following markup:

`

<TableRow android:id="@+id/tableRow1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@drawable/background_head" android:padding="5dp" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="match_parent" android:src="@drawable/cat_sled" /> <Button android:id="@+id/button1" style="@style/ThemeButtonHead" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:minHeight="40dp" android:minWidth="90dp" android:text="Button" android:textColor="@color/ColorHeadTextButton" android:textStyle="bold" /> </TableRow> 

`

I want to make the button on the right side, not how it does not go out. I would be grateful for the help.

And one more question

I wrote a markup page: `

 <ImageView android:id="@+id/imageView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:layout_marginTop="60dp" android:adjustViewBounds="true" android:maxHeight="150dp" android:maxWidth="150dp" android:src="@drawable/cat" /> <TextView android:id="@+id/Title1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/imageView1" android:layout_centerHorizontal="true" android:layout_marginTop="20dp" android:text="@string/Title1Text" android:textColor="@color/Title1Color" android:textSize="23sp" /> <TextView android:id="@+id/Title2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/Title1" android:layout_centerHorizontal="true" android:layout_marginTop="15dp" android:text="@string/Title2Text" android:textAppearance="?android:attr/textAppearanceSmall" android:textSize="20sp" /> <Button android:id="@+id/buttonStart" style="@style/ThemeButtonTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/Title2" android:layout_centerHorizontal="true" android:layout_marginTop="60dp" android:drawableLeft="@drawable/cat_sled" android:minHeight="48dp" android:onClick="onClickSound" android:text="@string/BStart" android:textColor="@color/Button1TitleColor" android:textSize="20sp" android:width="100dp" /> 

`I’m worried about whether it will normally display on devices with different screen sizes.

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

One of the options is to add a spacer (empty space) between the elements with the android:layout_weight="1" parameter android:layout_weight="1" all the available unallocated space in the container, this will push the outermost elements into the corners, leaving them only the necessary space:

 <TableRow android:id="@+id/tableRow1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@drawable/background_head" android:padding="5dp" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/cat_sled" /> <Space android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> <Button android:id="@+id/button1" style="@style/ThemeButtonHead" android:layout_width="wrap_content" android:layout_height="wrap_content" android:minHeight="40dp" android:minWidth="90dp" android:text="Button" android:textColor="@color/ColorHeadTextButton" android:textStyle="bold" /> </TableRow> 

PS: ImageView should have dimensions wrap_content in width and height, for Button android:layout_gravity="right" is completely superfluous.

On the second part of the question. In general, the rule here is: one question - one problem, but your second question can only be answered so that no one will test your markup on different devices for you - if there are not enough physical devices for tests, create emulators with different screen resolutions - phones , tablets, TVs and what else do you need there and test.
All the necessary information on the support of devices with different resolutions is fully collected here.