方法一:更换RadioButton的背景图片。(只能实现红色的提示点,不能实现数字提醒)
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>