Less nonsense, directly above the figure, there is a picture of the truth.
These two toolbars are all implemented using layout. Bottom Toolbar Layout code:
Code
Copy Code code as follows:
< xmlns:android= "Http://schemas.android.com/apk/res/android"
android:background= "@drawable/bottom"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/edit"
android:text= "Test"
Android:gravity= "Center_horizontal"
android:drawabletop= "@drawable/ic_dialog_alert"
Android:layout_alignparentleft= "true"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/menu2"
android:text= "Test"
Android:gravity= "Center_horizontal"
android:drawabletop= "@drawable/ic_dialog_dialer"
android:layout_torightof= "@id/edit"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/effect"
android:text= "Test"
Android:gravity= "Center_horizontal"
android:drawabletop= "@drawable/ic_dialog_email"
android:layout_torightof= "@id/menu2"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/menu3"
android:text= "Test"
Android:gravity= "Center_horizontal"
android:drawabletop= "@drawable/ic_dialog_info"
android:layout_torightof= "@id/effect"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
Top Toolbar Layout code:
Code
Copy Code code as follows:
<xmlns:android= "Http://schemas.android.com/apk/res/android"
android:background= "@drawable/top"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/undo"
android:src= "@drawable/ic_dialog_map"
Android:layout_alignparentleft= "true"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/save"
android:src= "@drawable/ic_dialog_menu_generic"
android:layout_torightof= "@id/undo"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/share"
android:src= "@drawable/ic_dialog_time"
android:layout_torightof= "@id/save"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
<android:id= "@+id/redo"
android:src= "@drawable/ic_dialog_usb"
android:layout_torightof= "@id/share"
Android:layout_width= "80dip"
android:layout_height= "Wrap_content"
>
Main Window Layout code:
Code
Copy Code code as follows:
<android:layout_height= "Fill_parent" >
Xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:id= "@+id/layout_topmenu"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:layout_alignparenttop= "true"
>
<android:text= "Asdfasdfas"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_below= "@id/layout_topmenu" >
<xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"
Android:layout_alignparentbottom= "true"
>
Main Window Code:
Code
Copy Code code as follows:
Package com.figoyu.photoqualify;
Import android.app.Activity;
Import Android.os.Bundle;
Import android.view.MotionEvent;
Import Android.view.View;
Import Android.view.Window;
Import Android.view.View.OnTouchListener;
Import Android.widget.ImageView;
Import Android.widget.TextView;
public class Mainactivity extends activity {
TextView txt1;
TextView Edittv;
ImageView imgbtn;
Boolean isfirst = true;
Boolean istopfirst = true;
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Requestwindowfeature (Window.feature_no_title);
Setcontentview (R.layout.main);
Edittv = (TextView) Findviewbyid (R.id.edit);
Txt1 = (TextView) Findviewbyid (R.ID.TXT1);
IMGBTN = (ImageView) Findviewbyid (R.id.undo);
Edittv.setontouchlistener (New Ontouchlistener () {
@Override
public boolean Ontouch (View V, motionevent event) {
if (Isfirst) {
Txt1.settext ("edit");
Edittv.setbackgrounddrawable (Getresources (). getdrawable (R.drawable.item_background));
Isfirst = false;
}else {
Txt1.settext ("Exit edit");
Edittv.setbackgrounddrawable (Getresources (). getdrawable (r.drawable.touming));
Isfirst = true;
}
return false;
}
});
Imgbtn.setontouchlistener (New Ontouchlistener () {
@Override
public boolean Ontouch (View V, motionevent event) {
if (Istopfirst) {
Txt1.settext ("edit");
Istopfirst = false;
}else {
Txt1.settext ("Exit edit");
Istopfirst = true;
}
return false;
}
});
}
}