android - dynamic layout with two buttons problem -


how can set buttons in linearlayout dynamically? want android mobiles different display sizes can use app.

code

<linearlayout android:id="@+id/linear_layout_main2" android:layout_width="fill_parent"  android:layout_height="wrap_content" android:orientation="horizontal">  <button android:id="@+id/bt1" android:text="go"    style="@style/button_font" android:clickable="false"      android:background="@drawable/box1"  android:layout_marginleft="6px" />  <button android:id="@+id/bt2" android:text="on"    style="@style/button_font" android:clickable="false"      android:background="@drawable/box1"  android:layout_marginleft="6px" />  </linearlayout>  

style-code

<style name="button_font" parent="@android:style/textappearance.medium">     <item name="android:layout_width">44px</item>     <item name="android:layout_height">39px</item>     <item name="android:textcolor">#ffffffff</item>     <item name="android:textsize">18px</item>     <item name="android:layout_gravity">center_vertical</item> </style> 

you can use android:layout_weight = "1" 2 button, take same screen ratio.

means 1:1 ratio put 2 buttons. works in screen sizes.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -