android底部菜单栏实现
2012-12-06 18:20
423 查看
一 TabHost
布局文件
二 TabHost+RadioGroup
布局文件
<?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" android:orientation="vertical" > <!-- @android:id/tabcontent 这个id必须是指定的 --> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" > </FrameLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" > <!-- @android:id/tabcontent 这个id必须是指定的 --> <!-- android:tabStripEnabled="false"去掉选项下划线 --> <TabWidget android:id="@android:id/tabs" android:tabStripEnabled="false" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="#1AD6D6" > </TabWidget> </RelativeLayout> </TabHost>
package com.tabhost1; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TabHost; public class TabHostDemo1Activity extends TabActivity { private TabHost tabHost; private Intent index,share,settting; /** * <!-- android:tabStripEnabled="false"去掉选项下划线 -->貌似在2.2的系统上才有效,低于这个系统的可以参考这个文章 * * http://blog.csdn.net/west8623/article/details/7481895 */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tabHost=getTabHost(); index=new Intent(this, IndexActivity.class); tabHost.addTab(tabHost.newTabSpec("index").setIndicator("首页", getResources().getDrawable(R.drawable.bottom_item_index_bg)).setContent(index)); share=new Intent(this, ShareActivity.class); tabHost.addTab(tabHost.newTabSpec("share").setIndicator("分享", getResources().getDrawable(R.drawable.bottom_item_share_bg)).setContent(share)); settting=new Intent(this,SettingActivity.class); tabHost.addTab(tabHost.newTabSpec("setting").setIndicator("设置", getResources().getDrawable(R.drawable.bottom_item_set_bg)).setContent(settting)); tabHost.setCurrentTabByTag("share");//设置当前选中标签 } }
package com.tabhost1; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class IndexActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textView=new TextView(this); textView.setText("首页"); setContentView(textView); } }省略两个Activity 跟IndexActivity一样
二 TabHost+RadioGroup
相关文章推荐
- Android RadioGroup+ViewPager+ActionBar实现仿微信6.0界面(底部滑动菜单栏+导航栏)
- Android仿UC底部菜单栏实现原理与代码
- 【Android UI设计与开发】第08期:底部菜单栏(三)Fragment+FragmentTabHost实现仿新浪微博底部菜单栏
- android实现底部菜单栏
- 【Android UI设计与开发】第06期:底部菜单栏(一)使用TabActivity实现底部菜单栏
- Android中实现底部弹出菜单栏
- Android开发Tabhost+RadioGroup实现底部菜单栏
- 【Android UI】RadioGroup+Fragment实现底部菜单栏
- android底部菜单栏实现原理与代码
- android底部菜单栏实现
- Android 底部菜单栏实现
- 【Android UI设计与开发】第06期:底部菜单栏(一)使用TabActivity实现底部菜单栏
- android tabhost底部菜单栏实现原理与代码
- Android TabHost +Fragment 实现底部菜单栏 .
- 【Android UI设计与开发】7.底部菜单栏(四)PopupWindow 实现显示仿腾讯新闻底部弹出菜单
- 【Android UI设计与开发】4.底部菜单栏(一)Fragment介绍和简单实现
- github开源组件实现android 底部菜单栏
- android底部菜单栏的实现和百度地图API的使用
- android实现上滑屏幕隐藏底部菜单栏的示例
- 我的Android之路——底部菜单栏的实现