android - How can I align an imagebutton under anothe one? -
i have 3 imagebuttons inside horizontal linearlayout , want add 1 more imagebutton right under left imagebutton(when left imagebutton starts , finishes, want same thing imagebutton under that). in vertital linearlayout. cannot align down imagebutton vertically one. how can that? ideas?
my code this:
android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_margintop="20dp" android:gravity="center"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton11" android:background="@drawable/image" android:layout_gravity="center" android:layout_marginright="30dp"/> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton12" android:background="@drawable/image" android:layout_gravity="center" android:layout_marginright="30dp"/> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton13" android:background="@drawable/image" android:layout_gravity="center" android:layout_marginright="30dp"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_margintop="20dp" android:gravity="left"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton14" android:background="@drawable/image" android:layout_marginright="30dp"/> </linearlayout>
you can more relativelayout via tablelayout or linearlayout. if willing use fixed widths imagebuttons (which should not problem imagebuttons), here 1 layout solve problem.
(i have used buttons in layout below sake of simplicity, work same imagebuttons well.)
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal"> <button android:layout_width="120dp" android:layout_height="wrap_content" android:id="@+id/btn1" android:text="button1" /> <button android:layout_width="120dp" android:layout_height="wrap_content" android:id="@+id/btn2" android:layout_torightof="@id/btn1" android:text="button2" /> <button android:layout_width="120dp" android:layout_height="wrap_content" android:id="@+id/btn3" android:layout_torightof="@id/btn2" android:text="button3" /> <button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button4" android:id="@+id/btn4" android:layout_below="@id/btn1" android:layout_alignleft="@id/btn1" android:layout_alignright="@id/btn1"/> </relativelayout> 
Comments
Post a Comment