Sunday, September 13, 2015

Android pre-defined Button style - buttonStyle, borderlessButtonStyle, buttonStyleToggle and buttonStyleInset


Some example of pre-defined Button style, include buttonStyle, borderlessButtonStyle, buttonStyleToggle and buttonStyleInset.


<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:orientation="vertical"
    android:padding="10dp"
    tools:context=".MainActivity">

    <TextView
        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="buttonStyle: Normal Button style"
        style="?android:attr/buttonStyle"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="borderlessButtonStyle: Style for buttons without an explicit border"
        style="?android:attr/borderlessButtonStyle"/>

    <ToggleButton
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textOn="ON - buttonStyleToggle: ToggleButton style"
        android:textOff="OFF - buttonStyleToggle: ToggleButton style"
        style="?android:attr/buttonStyleToggle"/>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="buttonStyleInset: Button style to inset into an EditText"
        style="?android:attr/buttonStyleInset"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button android:id="@+id/id_EditText_Button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="OK"
            style="?android:attr/buttonStyleInset"/>
        <EditText
            android:id="@+id/id_EditText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignTop="@+id/id_EditText_Button"
            android:layout_alignBottom="@+id/id_EditText_Button"
            android:layout_alignParentLeft="true"
            android:layout_toLeftOf="@id/id_EditText_Button"
            android:singleLine="true"
            android:hint="Enter Something" />

    </RelativeLayout>

</LinearLayout>




Related:
- Custom Color Button

No comments: