<>Button

inherit TextView

*
<> Text size , colour

*
Control layout file :

* <Button android:textSize="24sp" android:textColor="#a00de4"
android:background="#cfb0c8"/>
*
Or in shepe In layout ( We'll talk about how to create it later shepe Layout file )

* <solid android:color="#ff5960"/>
*
<> Custom background shape

*
First in res/drawable Under folder , Create a new one Drawble resource file, Type is shepe, Named :shape_1.xml

*
android:radius: Defines the fillet radius of the four corners .

*
Control layout reference :
<Button android:background="@drawable/shape_1"/>
*
shepe layout :

* <corners android:radius="20dp"/>
*
<> Custom press effect

*
First in res/drawable Under folder , Create a new one Drawble resource file, Type is selector, Named :sel__bnt1.xml

*
Control layout reference :

* android:background="@drawable/sel__bnt1"
*
selector layout :

* // When pressing <item android:state_pressed="true"> <shape> <solid android:color="
#FF9977"></solid> <corners android:radius="60dp"></corners> </shape> </item>
// When not pressed <item android:state_pressed="false"> <shape> <solid android:color="#CC7">
</solid> <corners android:radius="60dp"></corners> </shape> </item>
*
<> Click event

*
By creating a method , This method is then called in the control layout

*
* stay Activity Create in
* public void showToast(View view){ Toast.makeText(this," Don't order me !",Toast.
LENGTH_SHORT).show(); }
*
Called in the control layout

* <Button android:onClick="showToast" />
*
* Activity Direct declaration , Then add click reaction to the method
* private Button mBtn4; mBtn4 = findViewById(R.id.btn_4);
mBtn4.setOnClickListener(new View.OnClickListener() { @Override public void
onClick(View view) {
Toast.makeText(Activity3.this," You click the button below ",Toast.LENGTH_SHORT).show(); } });

Technology