android - How to place UI components uniformly using dip -
i need make below ui android app.
specifications:
ui contains total 4 sections (1-4).
component 1,2 & 4 must of same size.
component 3 must twice size of component 1.
but how can calculate exact dip
size component uniformly sized on different sized screens?
if approach wrong please advice.
thank you
if approach wrong please advice.
use vertical linearlayout
, android:layout_weight
on children. if pretend moment children buttons, use:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <button android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:text="1"/> <button android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="2" android:text="2"/> <button android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:text="3"/> <button android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" android:text="4"/> </linearlayout>
the result is:
Comments
Post a Comment