一、使用GridView布局
配置文件
<GridView android:id="@+id/GridView_toolbar" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_alignParentBottom="true"></GridView>
// 创建底部菜单 Toolbar toolbarGrid = (GridView) findViewById(R.id.GridView_toolbar); toolbarGrid.setBackgroundResource(R.drawable.channelgallery_bg);// 设置背景 toolbarGrid.setNumColumns(5);// 设置每行列数 toolbarGrid.setGravity(Gravity.CENTER);// 位置居中 toolbarGrid.setVerticalSpacing(10);// 垂直间隔 toolbarGrid.setHorizontalSpacing(10);// 水平间隔 toolbarGrid.setAdapter(getMenuAdapter(menu_toolbar_name_array, menu_toolbar_image_array));// 设置菜单Adapter /** 监听底部菜单选项 **/ toolbarGrid.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Toast.makeText(MainMenuView.this, menu_toolbar_name_array[arg2], Toast.LENGTH_SHORT) .show(); switch (arg2) { case TOOLBAR_ITEM_PAGEHOME: break; case TOOLBAR_ITEM_BACK: break; case TOOLBAR_ITEM_FORWARD: break; case TOOLBAR_ITEM_NEW: break; case TOOLBAR_ITEM_MENU: menuDialog.show(); break; } } });
二、使用tabHost来使用
http://flysnow.iteye.com/blog/946564
1、activity继承TabActivity
2、配置文件,使用自定义RadioButton取代,默认的tab风格,但是要不可见
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <!-- tabhost中的一个成员对象--> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0"/> <!-- 设置不可见了 --> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0" android:visibility="visible"/> <RadioGroup android:id="@+id/main_tab" android:background="@drawable/maintab_toolbar_bg" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:layout_gravity="bottom"> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/main_home" android:drawableTop="@drawable/icon_1_n" android:id="@+id/radio_button0" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/main_news" android:drawableTop="@drawable/icon_2_n" android:id="@+id/radio_button1" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/main_my_info" android:drawableTop="@drawable/icon_3_n" android:id="@+id/radio_button2" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/menu_search" android:drawableTop="@drawable/icon_4_n" android:id="@+id/radio_button3" style="@style/main_tab_bottom"/> <RadioButton android:layout_marginTop="2.0dip" android:text="@string/more" android:drawableTop="@drawable/icon_5_n" android:id="@+id/radio_button4" style="@style/main_tab_bottom"/> </RadioGroup> </LinearLayout> </TabHost>
4、activity中使用TabHost localHost=getTabHost();,新建选项卡,设置intent
/** * 构建TabHost的Tab页 * @param tag 标记 * @param resLabel 标签 * @param resIcon 图标 * @param content 该tab展示的内容 * @return 一个tab */ private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,final Intent content) { return this.mTabHost.newTabSpec(tag).setIndicator(getString(resLabel), getResources().getDrawable(resIcon)).setContent(content); }
5、使用此切换Activity,mTabHost.setCurrentTabByTag(TAB_TAG_HOME);就会自动调用intent
三、使用Fragment来布局
主页面 底部菜单采用自定义LinerLayOut生成。需要标记当前选中了哪一个。为每一个View配置监听器。
在MainActivity中实现显示与隐藏fragment
private void setFragmentIndicator(int whichIsDefault) { mFragments = new Fragment[3]; mFragments[0] = getSupportFragmentManager().findFragmentById(R.id.fragment_home); mFragments[1] = getSupportFragmentManager().findFragmentById(R.id.fragment_search); mFragments[2] = getSupportFragmentManager().findFragmentById(R.id.fragment_settings); getSupportFragmentManager().beginTransaction().hide(mFragments[0]) .hide(mFragments[1]).hide(mFragments[2]).show(mFragments[whichIsDefault]).commit(); FragmentIndicator mIndicator = (FragmentIndicator) findViewById(R.id.indicator); FragmentIndicator.setIndicator(whichIsDefault); mIndicator.setOnIndicateListener(new OnIndicateListener() { @Override public void onIndicate(View v, int which) { getSupportFragmentManager().beginTransaction() .hide(mFragments[0]).hide(mFragments[1]) .hide(mFragments[2]).show(mFragments[which]).commit(); } }); }
相关推荐
仿360底部菜单布局
本文主要是参考我的博客"[Android] 底部菜单布局+PopupWindows实现弹出菜单功能(初级篇)"完成,http://blog.csdn.net/eastmount/article/details/40827939.主要介绍实现类似美图秀秀的功能,在底部显示菜单,点击不同...
这是个仿携程旅行的主界面布局文件,大体做好了就差UI布局和代码的实现关联界面
安智市场UI框架布局之fragment+tabhost底部菜单
android fragment 使用以及嵌套使用 底部菜单和顶部菜单,类似微信和QQ的分页菜单
IOS开发源码-布局控件使用自定义UITableViewCell 导航及底部菜单后台获取功能等ISO代码合集: ios三级展开列表TQMultistageTableView_10802 ios个性化每个tableMHNibTableViewCell ios分页的滚动视图 IOS可扩展底部...
不用写布局、几句代码就可以实现底部菜单 Fragment切换
类似微信聊天界面底部菜单输入框与表情布局切换,发送按键切换
多种方式实现android上的底部菜单功能
1.vue+elementui实现,完整的后台管理系统界面布局源码; 2.左边菜单、顶部菜单、右边显示页面内容,可自定义修改拓展; 3.无可挑剔的样式。 4.创建一个规范的vue项目目录,直接替换项目文件即可
该源码支持实现支持底部菜单切换效果源码,基于现在都不太赞同用,于是简单地利用fragment 来实现了这一效果,IndexActivity为底部菜单的...底部菜单用的是一个自定义布局,效果非常不错,值得大家的借鉴与学习。
ImageView实现代码动态生成底部菜单,点击某个菜单自动冒出10dp,其他菜单自动底部对齐。(非布局实现)
效果图看上一版本http://www.apkbus.com/android-116690-1-1.html,上一版本是利用activitygroup实现底部菜单切换,基于现在都不太赞同用,于是简单地利用fragment ...底部菜单用的是一个自定义布局。分享给需要的伙伴
自定义菜单布局+ActivityGroup+多个Activity的方式实现仿新浪微博底部菜单更新UI) 详解:http://blog.csdn.net/pocoyoshamoo/article/details/24708715
几行代码实现一个项目的底部菜单功能,布局文件都省了,适用于百分98的项目。简单,易懂,包括内存回收状态的处理
用两种不同的方式实现了Android底部菜单栏的效果(也叫Tab选项卡)
也没那么多精力钻研太多,做开发的都懂得,适合新手看看还不错的框架,自己可以自行修改,中间使用了masonry 布局,初学者可以学习一下,框架本来想着用MVVM写,都放鸽子了,算了,就这样吧,还要继续些其他的项目,...
返照滴滴打车首页功能,左侧导航可以自定义,底部菜单可以上下拖动哦,而且左边可以侧滑出来,滴滴还不能侧滑出来呢;比网上别人各种忽略人下载的强多了,实际项目中拆分出来分享给大家的,谢谢支持,有问题按代码中...
本文要实现仿微信微信底部菜单栏+顶部菜单栏,采用ViewPage来做,每一个page对应一个XML,当手指在ViewPage左右滑动时,就相应显示不同的page(其实就是xml)并且同时改变底部菜单按钮的图片变暗或变亮,同时如果点击...