Android’de xml ile ilgili tasarım hakkında bir örneğimi daha önce sizlerle paylaşmıştım şimdi bu örneğimizde xml ile kıvrım ve kenarlık oluşturmayı göreceğiz.
ANDROID’de kıvrımlı ve kenarlıklı layout’lar oluşturma
Örneğimizin sonucunda aşağıdaki gibi bir sonuç elde edeceğiz.
Stilleri tanımladığımız rounded_corner.xml adlı dosyamız.
rounded_corner.xml(drawable)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#a9c5ac" /> <stroke android:width="3dp" android:color="#1c1b20"/> <padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp"/> <corners android:radius="10dp"/> </shape> |
Şimdi bu stili layout’umuzda kullanalım rounded_corner.xml adlı layout’umuz içerisine RelativeLayout’a hazırladığımız stil’i backgroun olarak atıyoruz.
rounded_corner.xml(layout)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="250dp" android:layout_height="250dp" android:background="@drawable/rounded_corner" android:layout_centerInParent="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="MURATONER.NET" android:textSize="25dp" android:layout_centerHorizontal="true" android:layout_centerVertical="true"/> </RelativeLayout> </RelativeLayout> |