Android仿QQ消息导航UI

1.layout_im_switch.xml文件部分
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	android:id="@+id/btn_header"
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent"
	android:layout_height="wrap_content">

	<LinearLayout
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_centerInParent="true"
		android:background="@drawable/im_switch_bg"
		android:padding="1dp">

		<RelativeLayout
			android:id="@+id/layout_family"
			android:layout_width="74dip"
			android:layout_height="match_parent">

			<Button
				android:id="@+id/btn_family"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:background="@android:color/transparent"
				android:gravity="center"
				android:singleLine="true"
				android:layout_centerInParent="true"
				android:text="家庭群"
				android:textColor="#03a9f4"
				android:textSize="14sp"/>

			<ImageView
				android:id="@+id/family_red_point"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignTop="@+id/btn_family"
				android:layout_toRightOf="@+id/btn_family"
				android:paddingTop="3dp"
				android:src="@drawable/im_item_red_point"
				android:visibility="visible"/>
		</RelativeLayout>

		<RelativeLayout
			android:id="@+id/layout_baby"
			android:layout_width="74dip"
			android:layout_height="match_parent"
			android:background="@drawable/im_baby">

			<Button
				android:id="@+id/btn_baby"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:background="@android:color/transparent"
				android:gravity="center"
				android:layout_centerInParent="true"
				android:singleLine="true"
				android:text="宝贝宝贝"
				android:textColor="#ffffff"
				android:textSize="14sp"/>

			<ImageView
				android:id="@+id/baby_red_point"
				android:layout_width="wrap_content"
				android:layout_height="wrap_content"
				android:layout_alignTop="@+id/btn_baby"
				android:layout_toRightOf="@+id/btn_baby"
				android:paddingTop="3dp"
				android:src="@drawable/im_item_red_point"
				android:visibility="visible"/>
		</RelativeLayout>
	</LinearLayout>
</RelativeLayout>

2.java文件code

	private View mTitleSwitchView = null;
	private View mLayoutFamily, mLayoutBaby;
	private Button mBtnFamily, mBtnBaby;
	private ImageView mFamilyRedPoint, mBabyRedPoint;

       <pre name="code" class="java">	mTitleSwitchView = mLayoutInflater.inflate(R.layout.layout_im_switch, null);
	mLayoutFamily = mTitleSwitchView.findViewById(R.id.layout_family);
	mLayoutBaby = mTitleSwitchView.findViewById(R.id.layout_baby);
	mFamilyRedPoint = (ImageView) mTitleSwitchView.findViewById(R.id.family_red_point);
	mBabyRedPoint = (ImageView) mTitleSwitchView.findViewById(R.id.baby_red_point);
	mBtnFamily = (Button) mTitleSwitchView.findViewById(R.id.btn_family);
	mBtnBaby = (Button) mTitleSwitchView.findViewById(R.id.btn_baby);
	mBtnFamily.setOnClickListener(this);
	mBtnBaby.setOnClickListener(this);

 
 
	@Override
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.btn_family:
				mBtnFamily.setTextColor(Color.parseColor("#03a9f4"));
				mLayoutFamily.setBackgroundColor(Color.TRANSPARENT);
				mBtnBaby.setTextColor(Color.parseColor("#ffffff"));
				mLayoutBaby.setBackgroundResource(R.drawable.im_baby);
				break;
			case R.id.btn_baby:
				mBtnBaby.setTextColor(Color.parseColor("#03a9f4"));
				mLayoutBaby.setBackgroundColor(Color.TRANSPARENT);
				mBtnFamily.setTextColor(Color.parseColor("#ffffff"));
				mLayoutFamily.setBackgroundResource(R.drawable.im_family);
				break;
		}
	}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值