How to achieve the following layout on Android -
i'm trying build following layout on android without success.
i want text displayed on screen. can take whole width, must centered horizontally.
on same line, on right side of screen want display small layout. shouldn't impact horizontal centering of main text , main text shouldn't visible behind layout displayed on right.
i cannot use hard color layout background it's displayed on transparent background on bitmap...
any idea on how achieve ?
i can either use relativelayout in case main text isn't centered based on middle of screen (it takes right layout width account) or text displayed behind right layout...
edit: here 1 of test
<relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:orientation="horizontal" > <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="bottom|center_horizontal" android:layout_centerinparent="true" android:fontfamily="sans-serif" android:layout_marginleft="2dp" android:layout_marginright="2dp" android:singleline="true" android:textcolor="?android:attr/textcolorprimary" android:textsize="17sp" android:text="very looooooooooooooooooooooooooooooooong text" android:textstyle="bold" /> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerinparent="true" android:layout_alignparentright="true" android:padding="3dp" android:visibility="visible" > <imageview android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="center_vertical" android:filter="true" android:src="@drawable/device_access_time" /> <spinner android:layout_width="20dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" /> </linearlayout> </relativelayout>
relativelayouts adhere principle of z-indexes, if put right-aligned layout first, centered text view drawn correctly on top.
Comments
Post a Comment