zoukankan      html  css  js  c++  java
  • 通过TabHost、RadioGroup实现菜单栏分栏

    main.xml

    <?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">
            <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="gone"/>
            <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>
    style.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <style name="main_tab_bottom">
        <item name="android:textSize">@dimen/bottom_tab_font_size</item>
        <item name="android:textColor">#ffffffff</item>
        <item name="android:ellipsize">marquee</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:background">@drawable/home_btn_bg</item>
        <item name="android:paddingTop">@dimen/bottom_tab_padding_up</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:button">@null</item>
        <item name="android:singleLine">true</item>
        <item name="android:drawablePadding">@dimen/bottom_tab_padding_drawable</item>
        <item name="android:layout_weight">1.0</item>
    </style>
    </resources>
    dimens.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <dimen name="bottom_tab_padding_drawable">2.0dip</dimen>
        <dimen name="bottom_tab_padding_up">5.0dip</dimen>
        <dimen name="bottom_tab_font_size">10.0dip</dimen>
    </resources>
    string.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="app_name">联系人</string>
        <string name="main_home">首页</string>
        <string name="main_news">信息</string>
        <string name="main_my_info">联系人</string>
        <string name="menu_search">搜索</string>
        <string name="more">更多</string>
    </resources>
  • 相关阅读:
    Link Maker 为 Apple Music、iTunes Store、App Store、iBooks Store 以及 Mac App Store 创建链接。
    在 CentOS7 上安装 MySQL5.7
    Git关于忽略Xcode工程中UserInterfaceState.xcuserstate文件的问题
    UITableView的frame改变做动画时,如何禁用UITableViewCell内置的动画效果
    Error: You must `brew link pcre openresty-openssl` before homebrew/nginx/openresty can be installed
    resty.upload 处理上传的图片 并把生成的url保存到数据库中
    Lua 计算两个GPS坐标点之间的距离
    Cornerstone安装提示文件已损坏问题
    "xxx was built without full bitcode" 编译错误解决
    iOS 网页打开APP,并且跳转到对应界面
  • 原文地址:https://www.cnblogs.com/mf0819/p/3826530.html
Copyright © 2011-2022 走看看