12- آموزش کامل Layout ها – بخش 4

خب به آخرین بخش آموزش جامع Layout ها رسیدیم در این قسمت Grid Layout در زامارین بررسی خواهد شد.
Grid Layout
نوعی ویوگروپ است که ویو های درون خودش را در یک گرید دوبعدی نمایش میدهد.

ساختار GridLayout
ساختار کلی این لیاوت بصورت زیر است که در آن row تعداد ردیف و column تعداد ستون است.

< ? xml version = "1.0" encoding = "utf-8" ? >
< GridLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:rowCount = "2"
android:columnCount = "2" >............</GridLayout>
ساخت یک GridLayout
برای ساخت یک گرید لیاوت ساده کد زیر را با کد main.axml جایگزین کنید.

< ? xml version = "1.0" encoding = "utf-8" ? >
< GridLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:rowCount = "2"
android:columnCount = "2" >
< TextView
android:text = "Cell 0"
android:textSize = "14dip" / >
< TextView
android:text = "Cell 1"
android:textSize = "14dip" / >
< TextView
android:text = "Cell 2"
android:textSize = "14dip" / >
< TextView
android:text = "Cell 3"
android:textSize = "14dip" / >
< / GridLayout >

کد بالا نتیجه ای به فرمت شکل زیر میسازد

مشخص کردن جهت گرید
کد زیر را اگر استفاده کنید جهت گرید را مانند تصویر تغییر میدهد.


< GridLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:rowCount = "2"
android:columnCount = "2"
android:orientation = "vertical" >
< / GridLayout >

آموزش کامل Layout ها در این قسمت تمام شد منتظر آموزش های بعدی ما باشید!
 




قسمت قبلی


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


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