码迷,mamicode.com
首页 > 移动开发 > 详细

Android 仿QQ首页的消息和电话的切换,首页的头部(完全用布局控制)

时间:2015-08-20 19:03:12      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:android   仿qq首页的消息和电话的切换   首页的头部完全用布局控制   radiobutton仿qq头部   布局实现   

Android 仿QQ首页的消息和电话的切换,首页的头部(完全用布局控制)

首先贴上七个控制布局代码

1.title_text_sel.xml 字体颜色的切换 放到color文件夹下面

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:color="@color/blue"/>
    <item android:state_checked="false" android:color="@color/white"/>
</selector>

2.rb_bg_01.xml左边RadioButton的背景选择

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_checked="true" android:drawable="@drawable/rb_bg_01t"></item>
    <item android:state_checked="false" android:drawable="@drawable/rb_bg_01f"></item>
</selector>

3.rb_bg_01f.xml左边RadioButton的背景选择

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

    <solid android:color="@color/blue"/>
	
    <corners android:topLeftRadius="15dip" android:bottomLeftRadius="15dip"/>
    
    <stroke android:width="1dip" android:color="@color/white_drak"/>
    
</shape>

4.rb_bg_01t.xml左边RadioButton的背景选择

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <solid android:color="@color/white_drak"/>
	
    <corners android:topLeftRadius="15dip" android:bottomLeftRadius="15dip"/>
    
</shape>

5.rb_bg_02.xml右边边RadioButton的背景选择

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_checked="true" android:drawable="@drawable/rb_bg_02t"></item>
    <item android:state_checked="false" android:drawable="@drawable/rb_bg_02f"></item>
</selector>

6.rb_bg_02f.xml右边边RadioButton的背景选择

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    
    <solid android:color="@color/blue"/>
	
    <corners android:topRightRadius="15dip" android:bottomRightRadius="15dip"/>
    
    <stroke android:width="1dip" android:color="@color/white_drak"/>

</shape>

7.rb_bg_02t.xml右边边RadioButton的背景选择

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

    <solid android:color="@color/white_drak"/>
	
    <corners android:topRightRadius="15dip" android:bottomRightRadius="15dip"/>
    
</shape>


activity_main.xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.atest.MainActivity" >

    <LinearLayout 
    android:layout_height="wrap_content"
    android:background="@color/blue"
    android:gravity="center"
    android:layout_width="match_parent">
        
        <RadioGroup  
        android:id="@+id/rg"  
        android:layout_margin="10dip"  
        android:layout_width="200dip"  
        android:layout_height="wrap_content" 
        android:layout_gravity="center"  
        android:orientation="horizontal">  
            <RadioButton   
            android:id="@+id/rb0"  
            android:layout_height="wrap_content"  
            android:layout_width="0dip"  
            android:layout_weight="1"  
            android:button="@null"  
            android:text="消息"  
            android:checked="true"
            android:textSize="16sp"  
            android:gravity="center"  
            android:paddingTop="6dip"
            android:paddingBottom="6dip"
            android:textColor="@color/title_text_sel"  
            android:background="@drawable/rb_bg_01"/>  
              
            <RadioButton   
            android:id="@+id/rb1"  
            android:layout_height="wrap_content"  
            android:layout_width="0dip"  
            android:layout_weight="1"  
            android:text="电话"  
            android:button="@null"  
            android:gravity="center" 
            android:textSize="16sp" 
            android:paddingTop="6dip"
            android:paddingBottom="6dip"
            android:textColor="@color/title_text_sel"  
            android:background="@drawable/rb_bg_02"/>  
    	</RadioGroup>  
    </LinearLayout>

</RelativeLayout>

colors.xml颜色值代码

<?xml version="1.0" encoding="utf-8"?>
<resources>
    
    <color name="blue">#18B4ED</color>
    <color name="white_drak">#D0EFFA</color>
    <color name="white">#FFFFFF</color>
    
</resources>


效果图

技术分享


源码下载:http://download.csdn.net/detail/pcaxb/9028951

版权声明:本文为博主原创文章,未经博主允许不得转载。

Android 仿QQ首页的消息和电话的切换,首页的头部(完全用布局控制)

标签:android   仿qq首页的消息和电话的切换   首页的头部完全用布局控制   radiobutton仿qq头部   布局实现   

原文地址:http://blog.csdn.net/pcaxb/article/details/47810329

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!