Skip to content

Instantly share code, notes, and snippets.

@lifeparticle
Created November 7, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lifeparticle/bd4095c5c705f1477be5 to your computer and use it in GitHub Desktop.
Save lifeparticle/bd4095c5c705f1477be5 to your computer and use it in GitHub Desktop.
apply layout_weight in a xml object so that it will have 20% of height and 80% of width
/**
* Author S Mahbub-Uz Zaman on November 8, 2015
* Lisence Under GPL2
*/
<?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"
android:weightSum="100">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="20"
android:orientation="horizontal"
android:weightSum="100">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="90"
android:background="@color/topic_bg">
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:padding="5dp"
android:text="dffsdfdf"
android:textColor="@android:color/white"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment