Android Measure Screen In Percentage
I did so many research on Android layouts i found so many answers but not found any answer which tells me how can i measure screen in actual percentage just found table layouts lin
Solution 1:
Percentage means ratio out of 100
Linear layout with weight is not difficult to manage you can technically manage linear layout in percentage like this,
Let suppose your main layout android:weightSum=”100” that mean your total screen size is 100% now you can specify every layouts width
Example
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><LinearLayoutandroid:id="@+id/layout"android:layout_width="fill_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:weightSum="100" ><TextViewandroid:id="@+id/one"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="12"android:background="#FF9933"android:text="No:" /><TextViewandroid:id="@+id/two"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="63"android:background="#CC33CC"android:text="Desc" /><TextViewandroid:id="@+id/three"android:layout_width="0dp"android:layout_height="fill_parent"android:layout_weight="25"android:background="#FF9999"android:text="Total" /></LinearLayout></LinearLayout>
according to percentage first column is 12% second is 63% and last one is 25%
Post a Comment for "Android Measure Screen In Percentage"