Android Wrap TextView to width of ImageButton -
i have linearlayout contains imagebutton, , underneath that, textview label. have textview centered, , have wrapped width of imagebutton underneath.
edit: should put code i'm using. here's linearlayout button , textview
<linearlayout android:id="@+id/contestlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <imagebutton android:id="@+id/contestbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/contestsbtnimg" android:layout_weight="1"> </imagebutton> <textview android:id="@+id/contestlabel" style="@style/mainmenustyle" android:text="@string/contests"> </textview> </linearlayout>
and here's relevant style declaration textview:
<style name="mainmenustyle" parent="android:style/textappearance"> <item name="android:textcolor">#000000</item> <item name="android:layout_centerhorizontal">true</item> <item name="android:textsize">12sp</item> <item name="android:singleline">false</item> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> </style>
what want imagebutton on top of linearlayout, textview acting label underneath, , wrapping text second line if wider button.
you should @ least try find solution yourself.
or give explanation why (and what) own findings were.
something should trick:
<linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="..."/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="...."/> </linearlayout>
Comments
Post a Comment