Android 仿微信的底部按钮的红色提示
2015-10-22 09:27
615 查看
方法一:更换RadioButton的背景图片。(只能实现红色的提示点,不能实现数字提醒)
方法二:在RadioButton上添加一层TextView,显示数字背景为红色图片。(能实现数字提醒)
效果图,如图所示:
在布局文件中,进行设置
RadioButton rb_new_1 = (RadioButton) findViewById(R.id.rb_new_1); Drawable drawable = getResources().getDrawable(R.drawable.bottom_1_selector); rb_new_1.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
方法二:在RadioButton上添加一层TextView,显示数字背景为红色图片。(能实现数字提醒)
效果图,如图所示:
在布局文件中,进行设置
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/background_img" android:clipToPadding="true" android:fitsSystemWindows="true" android:orientation="vertical" > <!-- <include layout="@layout/title_bar_small" /> --> <com.fengtai.customview.NoScrollViewPager android:id="@+id/view_pager" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_above="@+id/rl_bottom" android:layout_gravity="center" android:flipInterval="30" android:persistentDrawingCache="animation" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="58dp" android:layout_alignParentBottom="true" android:background="#151f2a" > </LinearLayout> <RelativeLayout android:id="@+id/rl_bottom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" > <RadioGroup android:id="@+id/radio_group" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <RadioButton android:id="@+id/rb_new_1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawablePadding="3dp" android:drawableTop="@drawable/bottom_1_selector" android:gravity="center" android:paddingBottom="6dp" android:text="我的工单" android:checked="true" android:textColor="@drawable/bottom_text_selector" android:textSize="13sp" /> <RadioButton android:id="@+id/rb_new_2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawablePadding="3dp" android:drawableTop="@drawable/bottom_home_selector" android:gravity="center" android:paddingBottom="6dp" android:text="我的绩效" android:textColor="@drawable/bottom_text_selector" android:textSize="13sp" /> <RadioButton android:id="@+id/rb_new_3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawablePadding="3dp" android:drawableTop="@drawable/bottom_paixun_selector" android:gravity="center" android:paddingBottom="6dp" android:text="培训考试" android:textColor="@drawable/bottom_text_selector" android:textSize="13sp" /> <RadioButton android:id="@+id/rb_new_4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:button="@null" android:drawablePadding="3dp" android:drawableTop="@drawable/bottom_jishi_selector" android:gravity="center" android:paddingBottom="6dp" android:text="即时通讯" android:textColor="@drawable/bottom_text_selector" android:textSize="13sp" /> </RadioGroup> </RelativeLayout> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignTop="@+id/rl_bottom"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:visibility="visible" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" android:gravity="right"> <TextView android:id="@+id/tv_unread" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/red_point_1" android:text="9" android:gravity="center" android:textColor="@color/white" android:layout_marginRight="8dp" android:textSize="12sp"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" android:gravity="right"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/red_point_1" android:text="9" android:gravity="center" android:textColor="@color/white" android:textSize="12sp"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" android:gravity="right"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/red_point_1" android:text="9" android:gravity="center" android:textColor="@color/white" android:textSize="12sp"/> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" android:gravity="right"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/red_point_1" android:text="9" android:gravity="center" android:textColor="@color/white" android:textSize="12sp"/> </LinearLayout> </LinearLayout> </RelativeLayout> </RelativeLayout>
相关文章推荐
- 微信开发学习日记(四):研究和部署开源产品
- 微信开发学习日记(二):3个案例
- 揭开智能配置上网(微信Airkiss)的神秘面纱
- 015.三元表达式与if条件句
- 微信填坑日志
- 微信红包签名算法 C#代码实现
- chrome插件 测试 接口利器 postman ,firefox 微信接口 淘宝api 测试利器 poster
- 如何判断微信内置浏览器(JS & PHP)
- 头疼,微信浏览器的控制
- 安装包立减1M--微信Android资源混淆打包工具
- 关闭微信浏览器
- 微信平台开发相关的问题记录
- 微信公众平台开发(98) UnionID
- 微信支付接口返回chooseWXPay:fail
- 微信公众账号开发入门
- 摘自微信之父张小龙内部8小时演讲
- 怎么让公众号的内容更有威力?
- 怎么让公众号的内容更有威力?
- Mac下使用微信Android资源混淆打包工具
- 通过UserAgent判断微信