Placing elements in horizontal layout (android) -
i want place imageview on center of screen , imagebutton on right of imageview, see screen.
how can this? tried horizontal linear layout , gravity: center both elements on center.
thanks in advance :)
the idea use relativelayout. set imageview in center of parent. put imagebutton on right of it. see example:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:orientation="vertical"> <textview android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff00ff00" android:text="text1"/> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffff0000"> <imageview android:id="@+id/main_image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerinparent="true" android:src="@drawable/ic_done_white_24px" /> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_torightof="@+id/main_image" android:src="@drawable/ic_account_box_black_24dp" /> </relativelayout> <textview android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#ff00ff00" android:gravity="center_vertical" android:text="text2"/> </linearlayout>
output:
Comments
Post a Comment