android - Align and wrap imagebuttons in linearlayout -
i have linearlayout
has imagebuttons
aligned horizontally, @ bottom of parent layout. exactly, want like:
this how doing it:
<linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="end|bottom" android:background="@color/dim_foreground_disabled_material_dark" android:orientation="horizontal"> <imagebutton android:id="@+id/new_1" android:background="@drawable/_dashboard_1" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <imagebutton android:id="@+id/new_2" android:background="@drawable/_dashboard_2" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <imagebutton android:id="@+id/new_3" android:background="@drawable/_dashboard_3" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </linearlayout>
i have tried give weightsum
linearlayout
, , assign weights
imagebuttons
. stretches aspect ratio of drawables.
how should use layout arrange them in bottom of view, evenly spaced, centrally placed , without stretched out aspect ratios of drawables..
if want achieve 1 using linearlayout try one..
<linearlayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:weightsum="10"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton10" android:src="@mipmap/ic_launcher" android:layout_marginleft="20dip" android:background="@android:color/transparent"/> <view android:layout_width="0dip" android:layout_weight="5" android:layout_height="1dip"/> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton9" android:src="@mipmap/ic_launcher" android:background="@android:color/transparent"/> <view android:layout_width="0dip" android:layout_weight="5" android:layout_height="1dip"/> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton8" android:src="@mipmap/ic_launcher" android:layout_marginright="20dip" android:background="@android:color/transparent"/> </linearlayout>
or if ok relativelayout try one...
<relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_centervertical="true" android:id="@+id/imagebutton12" android:src="@mipmap/ic_launcher" android:background="@android:color/transparent"/> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton11" android:layout_centerinparent="true" android:src="@mipmap/ic_launcher" android:background="@android:color/transparent"/> <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/imagebutton13" android:layout_alignparentright="true" android:layout_centervertical="true" android:src="@mipmap/ic_launcher" android:background="@android:color/transparent"/> </relativelayout>
Comments
Post a Comment