Android仿UC底部菜单栏实现原理与代码

最近刚看完ViewPager,开始我打算用自定义的imgBtn,但是发现放在pager选项卡中不好排版,所以最好选了GridView,接下来介绍底部菜单栏实现

相关的链接
Android 底部菜单栏实现

最近刚看完ViewPager,就想到做这样一个Demo,当然也参考了高手们的实例里边的网格菜单,开始我打算用自定义的imgBtn,但是发现放在pager选项卡中不好排版,所以最好选了GridView,简单实用

一、先主界面xml
activity_main.xml
复制代码 代码如下:

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
tools:context=".MainActivity" >

ViewPager中的三个选项卡xml
view_main.xml,view_set.xml,view_utils.xml
复制代码 代码如下:


android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#77ff0000"
android:orientation="vertical" >
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"
>



这是选项卡一view_main.xml,后面的两个和这个一样,就不发了
最后就是还有一个GirdView的适配器xml
复制代码 代码如下:


xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:id="@+id/imgbtn_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
/>
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" />


xml布局部分就这么多了

以上就是Android仿UC底部菜单栏实现原理与代码的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 移动