Android Button With Image and Text

Android Button represents a push button and it is a sub class TextView .


1. Android Button With Text
<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"/>


2. Android Image Button
<ImageButton 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:src="@android:drawable/ic_lock_idle_alarm"
    android:contentDescription="@string/button_label"/>


Android Button With Image and Text


1. Android Button With Left Drawable

<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:drawableStart="@android:drawable/ic_lock_idle_alarm"
    android:drawablePadding="10dp"
    android:gravity="start|center"/>


2. Android Button With Right Drawable
<Button android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:drawableEnd="@android:drawable/ic_lock_idle_alarm"
    android:drawablePadding="10dp"
    android:gravity="start|center"/>


3. Android Button With Top Drawable
<Button 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:drawableTop="@android:drawable/ic_lock_idle_alarm"
    android:drawablePadding="10dp"
    android:gravity="center"/>


4. Android Button With Bottom Drawable
<Button android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:drawableBottom="@android:drawable/ic_lock_idle_alarm"
    android:drawablePadding="10dp"
    android:gravity="center"/>


Android Button With Image Coloring


1. Android Button With Image Coloring
<Button android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:drawableStart="@android:drawable/ic_lock_idle_alarm"
    android:drawablePadding="10dp"
    android:gravity="start|center"
    android:drawableTint="@android:color/holo_red_dark"/>
                
2. Android ImageButton With Coloring
<ImageButton android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_label"
    android:src="@android:drawable/ic_lock_idle_alarm"
    android:contentDescription="@string/button_label"
    android:tint="@android:color/holo_red_dark"/>

No comments:

Post a comment