智慧北京:内容页面UI的实现

实现效果:


1、实现Content的布局

——content.xml——

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v4.view.ViewPager
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/bottom_tab_bg"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/content_home"
            style="@style/tap_style"
            android:drawableTop="@drawable/tab_home"
            android:text="@string/zhuye" />

        <RadioButton
            android:id="@+id/content_newscenter"
            style="@style/tap_style"
            android:drawableTop="@drawable/tab_newscenter"
            android:text="@string/news_center" />

        <RadioButton
            android:id="@+id/content_service"
            style="@style/tap_style"
            android:drawableTop="@drawable/tab_service"
            android:text="@string/intelligence_service" />

        <RadioButton
            android:id="@+id/content_govaffairs"
            style="@style/tap_style"
            android:drawableTop="@drawable/tab_govaffairs"
            android:text="@string/government_affairs" />

        <RadioButton
            android:id="@+id/content_set"
            style="@style/tap_style"
            android:drawableTop="@drawable/tab_set"
            android:text="@string/set" />
    </RadioGroup>

</LinearLayout>

2、设置样式style(因为此处的RadioButton具有以下相同的样式)

——style.xml——

 <style name="tap_style">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_weight">1</item>
        <item name="android:background">@android:color/transparent</item>
        <item name="android:button">@null</item>
        <item name="android:layout_gravity">center</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:textColor">@color/tab_text</item>
    </style>

3、设置按下、选择、松开效果

a:图片方面(5个)

——tab_home.xml——

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">


    <!-- 按下 -->
    <item android:drawable="@drawable/home_press" android:state_pressed="true"/>
    <!-- 选中 -->
    <item android:drawable="@drawable/home_press" android:state_checked="true"/>
    <!-- 其他 -->
    <item android:drawable="@drawable/home"/>


</selector>
b:文字方面(1个)

——tab_text.xml——

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 按下 -->
    <item android:state_pressed="true" android:color="@color/red"/>
    <!-- 选中 -->
    <item android:state_checked="true" android:color="@color/red"/>
    <!-- 其他 -->
    <item android:color="@color/white"/>

</selector>
4、修改主页面,将该content.xml显示出来
——ContentFragement.java——

package huaxa.it.zhihuidemo.fragment;

import huaxa.it.zhihuidemo.R;
import android.annotation.SuppressLint;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

/**
 * @项目名: ZhiHuiDemo
 * @包名: huaxa.it.zhihuidemo.fragment
 * @类名: ContentFragment
 * @创建者: 黄夏莲
 * @创建时间: 2016年10月5日 ,下午11:31:04
 * 
 * @描述: 内容页面
 */
public class ContentFragment extends BaseFragment
{

	@Override
	protected View initView()
	{

		View view = View.inflate(mActivity, R.layout.content, null);
		return view;
	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值