麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統 > Android > 正文

Android頂部工具欄和底部工具欄的簡單實現代碼

2020-04-11 12:18:40
字體:
來源:轉載
供稿:網友

廢話少說,直接上圖,有圖有真相。

這兩個工具欄全是用布局來實現的。底部工具欄布局代碼:

代碼

復制代碼 代碼如下:

   < 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="測試"
        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="測試"
        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="測試"
        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="測試"
        android:gravity="center_horizontal"
        android:drawableTop="@drawable/ic_dialog_info"
        android:layout_toRightOf="@id/effect"
        android:layout_width="80dip"
        android:layout_height="wrap_content"       
        >


頂部工具欄布局代碼:

代碼

復制代碼 代碼如下:

    <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"       
        >

主窗口布局代碼:

代碼

復制代碼 代碼如下:

    <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"
    >

主窗口代碼:

代碼

復制代碼 代碼如下:

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("編輯");
                    edittv.setBackgroundDrawable(getResources().getDrawable(R.drawable.item_background));
                    isFirst = false;
                }else {
                    txt1.setText("退出編輯");
                    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("編輯");                   
                    istopFirst = false;
                }else {
                    txt1.setText("退出編輯");                   
                    istopFirst = true;
                }               
                return false;
            }
        });
    }   
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 99精品视频一区二区三区 | 日本在线播放一区二区 | 欧美亚洲国产一区 | 爱看久久| 亚久久| 深夜福利视频免费观看 | 免费观看国产精品视频 | 羞羞羞网站 | 精品久久久久久久久久中文字幕 | 一级免费特黄视频 | 日本免费aaa观看 | 一级黄色国产视频 | 欧美一级黄色片免费观看 | 国产亚洲精品久久久久久网站 | 欧美激情在线播放 | 久久视频精品 | 国产免费一级大片 | 美国av片在线观看 | 日本爽快片100色毛片视频 | 国产成人av免费观看 | 欧美三级短视频 | 国产精品区一区二区三区 | 精品国产一区二区三区成人影院 | 日本一道aⅴ不卡免费播放 久久久久久久高清 | 韩国一级免费视频 | 国产精品亚洲激情 | 成人精品 | 久久午夜神器 | 久久久久久久久久久久久久av | 国产亚洲精品久久午夜玫瑰园 | 精品国产一区二 | 九一免费版在线观看 | 久久精品国产清自在天天线 | 精品亚洲夜色av98在线观看 | 久久久日韩av免费观看下载 | 久久精品一二三区白丝高潮 | 一区二区三区日韩精品 | 禁漫天堂久久久久久久久久 | 4399一级成人毛片 | 久久国产精品影视 | 一级免费特黄视频 |