先看效果图:
BadgeView对象可以结合其他控件可以在控件上面显示.具体用法可以自己百度,用起来很简单,我就不做多介绍了。
下面是我主要想表达的:
如果BadgeView与RadioGroup中的RadioButton结合后,RadioButton可以显示提示信息标志,但是就没办法切换界面了,这明显不是我想要的效果
但是前面我用Button来显示提示信息,还是可以点击跳转的,不影响其操作。
就想能不能两者结合起来呢。
答案是可以的。
思路就是把Button显示在RadioButton上面,而Button背景设为透明,这样用户看到的RadioButton。提示信息是捆绑在Button上面的哦,这个要注意。
下面是XML文件的代码
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_weight="1.0"/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.0"
android:visibility="gone"/>
<RadioGroup
android:id="@+id/main_tab"
android:background="@drawable/maintab_toolbar_bg"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_gravity="bottom">
<RadioButton
android:layout_marginTop="2.0dip"
android:text="@string/main_home"
android:drawableTop="@drawable/icon_1_n"
android:id="@+id/radio_button0"
style="@style/main_tab_bottom"/>
<RadioButton
android:layout_marginTop="2.0dip"
android:text="@string/main_news"
android:drawableTop="@drawable/icon_2_n"
android:id="@+id/radio_button1"
style="@style/main_tab_bottom"/>
<RadioButton
android:layout_marginTop="2.0dip"
android:text="@string/main_my_info"
android:drawableTop="@drawable/icon_3_n"
android:id="@+id/radio_button2"
style="@style/main_tab_bottom"/>
<RadioButton
android:layout_marginTop="2.0dip"
android:text="@string/menu_search"
android:drawableTop="@drawable/icon_4_n"
android:id="@+id/radio_button3"
style="@style/main_tab_bottom"/>
<RadioButton
android:layout_marginTop="2.0dip"
android:text="@string/more"
android:drawableTop="@drawable/icon_5_n"
android:id="@+id/radio_button4"
style="@style/main_tab_bottom"/>
</RadioGroup>
</LinearLayout>
<!-- 实现提醒信息用的 -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:background="#00000000"
android:layout_alignParentBottom="true"
>
<Button
android:visibility="invisible"
android:layout_height="fill_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<!-- 显示提醒信息的button android:layout_weight=1 是3个button,平分手机界面的宽度-->
<Button
android:id="@+id/bt"
android:layout_height="fill_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:background="#00000000"
/>
<Button
android:visibility="invisible"
android:layout_height="fill_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<Button
android:visibility="invisible"
android:layout_height="fill_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<Button
android:visibility="invisible"
android:layout_height="fill_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
</LinearLayout>
</RelativeLayout>
</TabHost>
主要是这个思路想法很好。
具体可以看:http://blog.csdn.net/hhhccckkk/article/details/16981561