Tuesday, December 25, 2018

Android Example - Circle shape in XML drawable file on Android

Android Example Hi Everyone. Circle shape used to customize images in a circle or display text in a circle. Today I will introduce you ... thumbnail 1 summary

Android Example Hi Everyone.

Circle shape used to customize images in a circle or display text in a circle.
Today I will introduce you to the lesson Circle shape in XML drawable this function applies a lot in each exercise and project of each of us, you can only follow the steps below.
 
Circle shape in XML drawable file on Android
Circle shape in XML drawable file on Android


The fist : res/drawable/custom_circle_shape.xml  on folder drawable.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <solid android:color="#800080"/>
            <!-- set width of cricle -->
            <stroke android:color="#3b91d7" android:width="5dp"/>
            <!-- set height of cricle -->
            <size android:width="250dp" android:height="250dp"/>
        </shape>
    </item>
</selector>

The second : activity_layout.xml on folder layout


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Circle shape in XML drawable"
        android:layout_gravity="center"
        android:textColor="#000"
        android:textSize="20sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Circular Shape"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:layout_centerInParent="true"
        android:background="@drawable/custom_circle_shape"
        android:textColor="#fff"
        />
</LinearLayout>


Tags: Android, Cricle shape, custom button, android example

1 comment

  1. Cúp golf
    Mỗi một món quà tặng cúp golf pha lê vinh danh đều tạo những ấn tượng sâu sắc và độc đáo cùng dấu ấn rất riêng của từng đơn vị nhằm mang đến những sản phẩm quà tặng khen thưởng nhân viên, tri ân khách hàng hoàn hảo nhất. Tùy vào từng mục đích, sự kiện mà ta có những cách lựa chọn cúp pha lê riêng.
    Cúp golf
    Xưởng sản xuất cúp golf chất liệu pha lê sang trọng. Chế Tác Theo Yêu Cầu. Miễn Phí Thiết Kế, Miến Phí Giao Hàng, Có Hộp Đựng
    Cúp golf

    ReplyDelete