9- آموزش کامل Layout ها – بخش 1

در قسمت قبل ویو AutoCompleteTextView رو بررسی کردیم حال در این بخش به بررسی کامل Layout های اندروید میپردازیم.
در این بخش قصد داریم Linear Layout را به شما آموزش دهیم.
Linear Layout
یک ویوگروپ (ViewGroup) هست که ویو های درون خودش رو به دو صورت افقی و عمودی نشون میده.




صورت کلی LinearLayout بصورت زیر هست :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

در قسمت orirentation جهت مشخص میشود که عمودی است یا افقی برای عمودی vertical  و برای افقی horizontal قرار دهید در محل …… نیز ویو ها قرار خواهند گرفت
برای ساخت نمونه عکس های داده شده کد های زیر را در Main.axml قرار دهید.
حالت عمودی:

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="50"
android:gravity="center_horizontal"
android:background="#eceff1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="100"
android:gravity="center_horizontal"
android:background="#cfd8dc"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="200"
android:gravity="center_horizontal"
android:background="#b0bec5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="300"
android:gravity="center_horizontal"
android:background="#90a4ae"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="400"
android:gravity="center_horizontal"
android:background="#78909c"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="500"
android:gravity="center_horizontal"
android:background="#607d8b"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="600"
android:gravity="center_horizontal"
android:background="#546e7a"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="700"
android:gravity="center_horizontal"
android:background="#455a64"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="800"
android:gravity="center_horizontal"
android:background="#37474f"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:text="900"
android:gravity="center_horizontal"
android:background="#263238"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>

حالت افقی:

<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:text="50"
android:gravity="center_horizontal"
android:background="#eceff1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="100"
android:gravity="center_horizontal"
android:background="#cfd8dc"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="200"
android:gravity="center_horizontal"
android:background="#b0bec5"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="300"
android:gravity="center_horizontal"
android:background="#90a4ae"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="400"
android:gravity="center_horizontal"
android:background="#78909c"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="500"
android:gravity="center_horizontal"
android:background="#607d8b"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="600"
android:gravity="center_horizontal"
android:background="#546e7a"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="700"
android:gravity="center_horizontal"
android:background="#455a64"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="800"
android:gravity="center_horizontal"
android:background="#37474f"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
<TextView
android:text="900"
android:gravity="center_horizontal"
android:background="#263238"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>





قسمت قبلی


فهرست تمامی قسمت ها


قسمت بعدی انشالله به زودی…