Mono 平台 安卓 APP 菜单栏制作
2014-12-25 15:58
363 查看
介绍安卓APP 底布菜单的制作
效果图如下:
现在开始上Ui设计的代码:
Main.axml
源码送上
效果图如下:
现在开始上Ui设计的代码:
Main.axml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minWidth="25px" android:minHeight="25px"> <TabHost android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:id="@+id/tabHost1"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/linearLayout1"> <TabWidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> <RadioGroup android:id="@+id/bottom_group" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="@drawable/group_background" android:gravity="center_vertical" android:orientation="horizontal"> <RadioButton android:id="@+id/radio_home" style="@style/radio_navigation_bar_bottom_tab" android:checked="true" android:drawableTop="@drawable/tab_home" android:text="Tab1" /> <RadioButton android:id="@+id/radio_letter" style="@style/radio_navigation_bar_bottom_tab" android:drawableTop="@drawable/tab_reference" android:text="Tab2" android:enabled="true" /> <RadioButton android:id="@+id/radio_comment" style="@style/radio_navigation_bar_bottom_tab" android:drawableTop="@drawable/tab_reference" android:text="Tab3" android:enabled="true" /> <RadioButton android:id="@+id/radio_more" style="@style/radio_navigation_bar_bottom_tab" android:drawableTop="@drawable/tab_more" android:text="Tab4" /> </RadioGroup> </LinearLayout> </TabHost> </LinearLayout>这里是最重要的代码:(对应Main.axml)
using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; namespace Tab { [Activity(Label = "Tab", MainLauncher = true, Icon = "@drawable/ic_launcher")] public class MainActivity : Activity, View.IOnClickListener { private RadioGroup group; private TabHost tabHost; private String tab_home_bar = "tab_home"; private String tab_letter_bar = "tab_letter"; private String tab_comment_bar = "tab_comment"; private String tab_more_bar = "tab_more"; private RadioButton radio_home; private RadioButton radio_letter; private RadioButton radio_comment; private RadioButton radio_more; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); init(); LocalActivityManager localActMgr = new LocalActivityManager(this, false); localActMgr.DispatchCreate(bundle); tabHost.Setup(localActMgr); setNavigationBar(); } private void init() { //group = FindViewById<RadioGroup>(Resource.Id.bottom_group); //group.SetOnClickListener(this); radio_home = FindViewById<RadioButton>(Resource.Id.radio_home); radio_letter = FindViewById<RadioButton>(Resource.Id.radio_letter); radio_comment = FindViewById<RadioButton>(Resource.Id.radio_comment); radio_more = FindViewById<RadioButton>(Resource.Id.radio_more); radio_home.SetOnClickListener(this); radio_letter.SetOnClickListener(this); radio_comment.SetOnClickListener(this); radio_more.SetOnClickListener(this); tabHost = FindViewById<TabHost>(Resource.Id.tabHost1); } private void setNavigationBar() { TabHost.TabSpec tab_home = tabHost.NewTabSpec(tab_home_bar); TabHost.TabSpec tab_letter = tabHost.NewTabSpec(tab_letter_bar); TabHost.TabSpec tab_comment = tabHost.NewTabSpec(tab_comment_bar); TabHost.TabSpec tab_more = tabHost.NewTabSpec(tab_more_bar); tab_home.SetIndicator(tab_home_bar).SetContent(new Intent(this, typeof(Activity1))); tab_letter.SetIndicator(tab_letter_bar).SetContent(new Intent(this, typeof(Activity2))); tab_comment.SetIndicator(tab_comment_bar).SetContent(new Intent(this, typeof(Activity3))); tab_more.SetIndicator(tab_more_bar).SetContent(new Intent(this, typeof(Activity5))); tabHost.AddTab(tab_home); tabHost.AddTab(tab_letter); tabHost.AddTab(tab_comment); tabHost.AddTab(tab_more); tabHost.CurrentTab = 1; } public void OnClick(View v) { switch (v.Id) { case Resource.Id.radio_home: tabHost.SetCurrentTabByTag(tab_home_bar); break; case Resource.Id.radio_letter: tabHost.SetCurrentTabByTag(tab_letter_bar); break; case Resource.Id.radio_comment: tabHost.SetCurrentTabByTag(tab_comment_bar); break; case Resource.Id.radio_more: tabHost.SetCurrentTabByTag(tab_more_bar); break; } } } }
源码送上
相关文章推荐
- 移动开发平台-应用之星app制作教程
- App手机应用自建平台 无需编码技术 轻松制作
- 如何快速制作App应用软件?国内有哪些比较好用的App制作平台?
- 安卓应用App发布至各大平台汇总
- 高效的APP在线制作平台,让梦想轻松孵化器
- app开发平台-应用之星app制作教程
- RF Analyzer for Android 安卓平台连接HackRF的App
- 手机APP软件制作平台搭建(基于windows)
- APP在线制作平台,手机应用,手机App开发,手机客户端开发
- 免费APP制作平台哪个好,我能自己制作APP吗?
- 智能手机技术飞速发展 手机APP制作平台异军突起
- 广州app制作:那个手机app制作平台好?
- 安卓app下载及制作入门教程
- 手机APP制作平台异军突起
- APP在线制作平台,终极技术哪家强?
- 移动开发平台-应用之星app制作教程
- 盘点国内外在线app制作平台:分分钟做款app
- 安卓天气查询预报APP软件的制作
- APP切图的那点事——安卓与iOS平台切图小结
- RF Analyzer for Android 安卓平台连接HackRF的App