Android选项卡栏
是否有可能在android选项卡栏中添加通知,就像在iPhone标签中一样。我不是指通知。在这里,我也将放置iPhone徽章屏幕截图Android选项卡栏,android,Android,是否有可能在android选项卡栏中添加通知,就像在iPhone标签中一样。我不是指通知。在这里,我也将放置iPhone徽章屏幕截图 如果android中没有徽章,将视图放在选项卡栏前面是一个很好的解决方案吗?就是您想要的吗?无法在选项卡上添加徽章或小视图。 但是,您可以创建自定义选项卡,若要在每个视图上添加这些选项卡,请覆盖setContentView()在设置内容视图之前,请在每个活动中创建并处理自定义选项卡。这样做的可能方式是将其包含在Android项目中,然后使用BadgeView对象。
如果android中没有徽章,将视图放在选项卡栏前面是一个很好的解决方案吗?就是您想要的吗?无法在选项卡上添加徽章或小视图。
但是,您可以创建自定义选项卡,若要在每个视图上添加这些选项卡,请覆盖setContentView()在设置内容视图之前,请在每个活动中创建并处理自定义选项卡。这样做的可能方式是将其包含在Android项目中,然后使用BadgeView对象。您可以创建自定义选项卡项xml,并放置带有背景图像和centerInParent文本视图的RelativeLayout。将RelativeLayout的visibility设置为GONE,并且无论何时您想要显示它,都要使其可见,并将textview设置为您想要的任何文本
<RelativeLayout
android:id="@+id/tabBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="47dp"
android:layout_marginTop="10dp"
android:layout_toStartOf="@+id/tabTitle"
android:visibility="gone" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/basket_item"
android:contentDescription="@string/action_settings" />
<TextView
android:layout_centerInParent="true"
android:id="@+id/tabBadgeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="10sp" />
</RelativeLayout>
希望有帮助,如果您需要更多信息,请随时提问。也许您之前的一些问题有您可以接受的答案?在android中,这很容易做到,请检查我的答案
// mTitle is the title of the tab
if (mTitle.equalsIgnoreCase("Basket")) {
//count is the TextView inside your badge
count = (TextView) view.findViewById(R.id.tabBadgeText);
//layout is the whole badge's layout
layout = (RelativeLayout) view.findViewById(R.id.tabBadge);
}