Sunday, September 20, 2015

Simple buttons with drawable

Example of buttons with drawable/icon:


<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:padding="16dp"
    android:orientation="vertical"
    tools:context=".MainActivity">
    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:autoLink="web"
        android:text="http://android-er.blogspot.com/"
        android:textStyle="bold" />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Normal Button"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="borderlessButtonStyle"
        style="?android:attr/borderlessButtonStyle"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableRight="@android:drawable/ic_dialog_info"
        android:text="Normal Button with drawable"/>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="borderlessButtonStyle with drawable"
        android:drawableRight="@android:drawable/ic_dialog_info"
        style="?android:attr/borderlessButtonStyle"/>
    <ImageButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_dialog_info"/>
    <ImageButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="borderlessButtonStyle"
        android:src="@android:drawable/ic_dialog_info"
        style="?android:attr/borderlessButtonStyle"/>
</LinearLayout>


No comments: