LİNEAR LAYOUT 3
Arkadaşlar bugun hem renkli tuş hemde gravity ile linnerlayouttda view nerden konumlandırılacagına anlattık gravity ile ortadamı,sagındamı.. nerde konumlandıracagımıza kara verdik.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
//Burda bu şekilde nerden itibaren konumlanacagını belirtmiş olduk.
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn1"
android:background="@color/colorPrimary"
android:text="Mavi"
android:textColor="@color/colorAccent"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2"
android:background="@color/colorPrimary"
android:text="Kırmızı"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn3"
android:background="@android:color/holo_blue_light"
android:text="Yeşil"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn4"
android:background="@android:color/holo_blue_bright"
android:text="Kırmızı"/>
//Lineer Layoutta altında ustunde demeyız cunku alt alta yerlestrır relatıvelayoutda ise bulundugu konuma gore belirlenir digerinin
//rengi
</LinearLayout>
Arkadaşlar burda butun tusların aynı boyutta olmasını istiyorsak gravityin ustunde weightsum fonksiyonunu tanımlayıp 1 degeri veriyoruz daha sonra oluşturdugumuz ik adet butonda
layout_weigt degerini 0.5 girerek tanımladıgımızda tam eşit şekilde butonlar oluşmaktadır.Bu layout_weight ile ekrana gore yuzde hesaplanarak yazılması gerekmektedir.Biz iki adet buton bulundugu için 0.5 dedik
eger 4 adet butonumuz olsaydı 0.25 dememiz gerekmektedir.