Sunday, July 7, 2019

Custom button with icon and text in Android

Today I will introduce to you the Custom button with icon and text in android the article is quite an Android or, currently in our project requests from clients force us to custom button in android beautiful, to understand that function, we have to request custom button in android so that users know the role and uses of the function that is nothing, so we have to make the Example android custom button, here are the steps to accomplish custom button image with text in android that.
res/drawable/ circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="1000dp" />
    <solid android:color="#41ba7a" />
    <stroke
        android:width="2dip"
        android:color="#03ae3c" />
    <padding
        android:bottom="4dp"
        android:left="4dp"
        android:right="4dp"
        android:top="4dp" />
</shape>
res/layout/custom_button.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:padding="16dp">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="@drawable/circle"
            android:drawableTop="@android:drawable/ic_dialog_email"
            android:paddingTop="20dp"
            android:text="Contact"
            android:textColor="#fff" />
        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_marginLeft="10dp"
            android:background="@drawable/circle"
            android:drawableTop="@android:drawable/ic_dialog_map"
            android:paddingTop="20dp"
            android:text="Map"
            android:textColor="#fff" />
        <Button
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_marginLeft="10dp"
            android:background="@drawable/circle"
            android:drawableTop="@android:drawable/ic_dialog_info"
            android:paddingTop="20dp"
            android:text="Info"
            android:textColor="#fff" />
    </LinearLayout>
</LinearLayout>
src/ ButtonCustom.java
public class RoundedAndroidButton extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.circular_button_with_image_and_text);
    }
}
res/values/strings.xml
<resources>
    <string name="app_name">Circular Button with Icon and Text</string>
</resources>
Success :
Custom button with icon and text in Android

No comments:

Post a Comment