Linear Layout Android

 on Selasa, 07 Juni 2016  

LinearLayout
LinearLayout yaitu tampilan yang cuma bisa menempatkan 1 widget per baris/kolom. Jika ingin 1 widget/baris, maka harus menggunakan orientation: vertical, dan jika 1 widget/kolom harus menggunakan orientation:horizontal jadi linearlayout geraknya terbatas gan

1.Linear Layout dengan orientation vertical




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="match_parent"
 android:layout_width="match_parent"
 android:orientation="vertical">
 
 <!-- widget utama -->

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#C8332A"/>

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#5823D4"/>

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#C9E912"/>

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#3CE320"/>
 
 <!-- widget utama -->

</LinearLayout>
2.Linear Layout dengan orientation center vertical




<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="match_parent"
 android:layout_width="match_parent"
 android:orientation="vertical"
 android:gravity="center_vertical">
 
 <!-- widget utama -->

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#C8332A"/>

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#5823D4"/>

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#C9E912"/>

 <TextView
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="match_parent"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#3CE320"/>
 
 <!-- widget utama -->

</LinearLayout>
3.Linear Layout dengan orientation horizontal



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="match_parent"
 android:layout_width="wrap_content"
 android:orientation="horizontal"
 android:gravity="center_horizontal">
 
 <!-- widget utama -->

 <TextView
  android:layout_height="match_parent"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="wrap_content"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#C8332A"/>

 <TextView
  android:layout_height="match_parent"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="wrap_content"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#5823D4"/>

 <TextView
  android:layout_height="match_parent"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="wrap_content"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#C9E912"/>

 <TextView
  android:layout_height="match_parent"
  android:textAppearance="?android:attr/textAppearanceLarge"
  android:layout_width="wrap_content"
  android:text="Large Text"
  android:gravity="center_horizontal"
  android:background="#3CE320"/>
 
 <!-- widget utama -->

</LinearLayout>
Full Source Code

Linear Layout Android 4.5 5 Aldy Putra Selasa, 07 Juni 2016 LinearLayout LinearLayout yaitu tampilan yang cuma bisa menempatkan 1 widget per baris/kolom. Jika ingin 1 widget/baris, maka harus mengg...


Tidak ada komentar:

Posting Komentar

J-Theme