a亚洲精品_精品国产91乱码一区二区三区_亚洲精品在线免费观看视频_欧美日韩亚洲国产综合_久久久久久久久久久成人_在线区

首頁 > 系統 > Android > 正文

Android仿UC底部菜單欄實現原理與代碼

2020-04-11 12:35:18
字體:
來源:轉載
供稿:網友
相關的鏈接
Android 底部菜單欄實現

最近剛看完ViewPager,就想到做這樣一個Demo,當然也參考了高手們的實例里邊的網格菜單,開始我打算用自定義的imgBtn,但是發現放在pager選項卡中不好排版,所以最好選了GridView,簡單實用

一、先主界面xml
activity_main.xml
復制代碼 代碼如下:

<RelativeLayout 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:background="@drawable/bg"
tools:context=".MainActivity" >
<Button
android:id="@+id/btn_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="show/hide Menu" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_menu"
android:gravity="center"
android:orientation="horizontal" >
<com.example.myMenu.MyImgBtn
android:id="@+id/main_btn1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_weight="1" />
<com.example.myMenu.MyImgBtn
android:id="@+id/main_btn2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_weight="1" />
<com.example.myMenu.MyImgBtn
android:id="@+id/main_btn3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_weight="1" />
<com.example.myMenu.MyImgBtn
android:id="@+id/main_btn4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:layout_weight="1" />
</LinearLayout>
<RelativeLayout
android:id="@+id/layout_menu"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true" >
<LinearLayout
android:id="@+id/menu"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#dd000000"
android:gravity="center" >
<TextView
android:id="@+id/tv_main"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="常用"
android:textColor="#ffffffff" />
<TextView
android:id="@+id/tv_utils"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="工具"
android:textColor="#ffffffff" />
<TextView
android:id="@+id/tv_set"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="設置"
android:textColor="#ffffffff" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_anim"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/menu"
android:background="#eeff8c00" >
<ImageView
android:id="@+id/iv_cursor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="matrix"
android:src="@drawable/img_cursor" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="@+id/myPager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_anim"
android:flipInterval="30"
android:persistentDrawingCache="animation" />
</RelativeLayout>
</RelativeLayout>

ViewPager中的三個選項卡xml
view_main.xml,view_set.xml,view_utils.xml
復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#77ff0000"
android:orientation="vertical" >
<GridView
android:id="@+id/myGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="4"
android:layout_margin="10dp"
android:horizontalSpacing="20dp"
android:gravity="center"
android:verticalSpacing="20dp"
></GridView>
</LinearLayout>

這是選項卡一view_main.xml,后面的兩個和這個一樣,就不發了
最后就是還有一個GirdView的適配器xml
復制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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" >
<ImageView
android:id="@+id/imgbtn_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/imgbtn_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imgbtn_img"
android:layout_centerHorizontal="true"
android:text="Text"
android:textColor="#ff0000ff"
android:textSize="10sp" />
</RelativeLayout>

xml布局部分就這么多了
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 自拍亚洲 | 久久激情网| 亚洲国产成人精品女人 | 国产精品视频男人的天堂 | 国产高潮呻吟久久渣男片 | 北条麻妃99精品青青久久主播 | 噜噜噜噜狠狠狠7777视频 | 亚洲欧洲无码一区二区三区 | 91亚洲国产精品 | 青青草久草 | 偷拍自拍网站 | 97国产超碰 | 成人免费视频观看视频 | 久草视频在线资源站 | 99久草 | 亚洲v欧美 | 久久久久久久久久97 | 久久久久国产 | 日韩网站在线 | 午夜影院a | 九九在线视频 | 毛片毛片毛片毛片毛片毛片毛片毛片毛片毛片 | 亚洲一区二区av | 免费色在线 | 后进极品白嫩翘臀在线视频 | 日韩在线你懂的 | 日韩高清在线一区 | 久久综合亚洲 | 久久精品亚洲 | 一区二区不卡 | 国产精品亲子伦av一区二区三区 | 欧美视频亚洲视频 | 九色在线 | 中文字幕av一区二区 | 久久久久国产精品午夜一区 | 精品一区二区三区免费毛片爱 | 欲色av | 97免费在线视频 | 日韩精品视频一区二区三区 | 国产精品电影在线观看 | 国产精品视频久久久 |