The button UI element is a simple customizable button UI element. The following image shows some examples:
![]() |
![]() |
---|
You need to create a new com.att.widgets.lib.button.StaticTextButton object and add it to your view or layout.
<LinearLayout xmlns:att="http://schemas.android.com/apk/res/com.att.statictextbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="20sp" android:orientation="vertical" android:background="#FFFFFFFF"> <com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Blue" android:layout_marginBottom="10sp" /> <com.att.widgets.lib.button.StaticTextButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Blue" android:layout_marginBottom="10sp" android:enabled="false" /> </LinearLayout>
Attribute that defines the type in xml : att:buttonType
<com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Highlighted" att:buttonType="primary_highlighted" android:layout_marginBottom="10sp" />
Complete XML code
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:att="http://schemas.android.com/apk/res/com.att.statictextbutton" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFFFF" android:padding="20sp" android:orientation="vertical" > <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="20sp" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="These are the sample action buttons" android:textColor="#000000" /> <com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Blue" android:layout_marginBottom="10sp" /> <com.att.widgets.lib.button.StaticTextButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Blue" android:layout_marginBottom="10sp" android:enabled="false" /> <com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Highlighted" att:buttonType="primary_highlighted" android:layout_marginBottom="10sp" /> <com.att.widgets.lib.button.StaticTextButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Highlighted" att:buttonType="primary_highlighted" android:layout_marginBottom="10sp" android:enabled="false"/> <com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Warning" att:buttonType="primary_warning" android:layout_marginBottom="10sp" /> <com.att.widgets.lib.button.StaticTextButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Primary Button Warning" att:buttonType="primary_warning" android:layout_marginBottom="10sp" android:enabled="false"/> <com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Secondary Button Black" att:buttonType="secondary_black" android:layout_marginBottom="10sp" /> <com.att.widgets.lib.button.StaticTextButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Secondary Button Black" att:buttonType="secondary_black" android:layout_marginBottom="10sp" android:enabled="false"/> <com.att.widgets.lib.button.StaticTextButton android:id="@+id/btn5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Secondary Button White" att:buttonType="secondary_white" android:layout_marginBottom="10sp" /> <com.att.widgets.lib.button.StaticTextButton android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Secondary Button White" att:buttonType="secondary_white" android:layout_marginBottom="10sp" android:enabled="false"/> </LinearLayout> </ScrollView> </LinearLayout>
import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Toast; public class StaticTextButtonActivity extends Activity implements View.OnClickListener{ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); StaticTextButton btn1= (StaticTextButton) this.findViewById(R.id.btn1); btn1.setOnClickListener(this); } @Override public void onClick(View v) { //put your code here!!! //Example Toast.makeText(this, "Selected!" , Toast.LENGTH_SHORT).show(); } }
There are 5 styles of buttons, you can change the predefined style with the buttonType property
ButtonType |
Description |
---|---|
primary |
Blue Primary Button |
primary_highlighted |
Highlighted Button |
primary_warning |
Red Warning Button |
secondary_black |
Black Secondary Button |
secondary_white |
White Secondary Button |