好多人问怎么实现tab上有数字,其实很简单实现方法有很多,这里有布局实现吧,只是demo,希望大家明白原理res/drawable/shapecount.xml

<?xml version="1.0" encoding="utf-8"?><shape    xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="rectangle">  <corners android:radius="20dp"  />      <solid android:color="#ff2233" /></shape>

res/layout/tabicon.xml<RelativeLayout    android:orientation="vertical"    android:background="@null"    android:id="@+id/rlayout"    android:layout_width="wrap_content"    android:layout_height="wrap_content" >    <ImageView             android:id="@+id/icon"            android:src="@android:drawable/ic_menu_mylocation" <!-- Just for test -->            android:layout_margin="0dp"            android:layout_height="wrap_content"             android:layout_width="wrap_content"/>    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"        android:text="50" android:textSize="12dp" android:textStyle="bold"          android:background="@drawable/shapecount"        android:textColor="#FFFFFF"        android:paddingLeft="3dp" android:paddingRight="3dp"            android:layout_margin="0dp"        android:layout_alignBottom="@+id/rlayout"        android:id="@+id/txtCount" /></RelativeLayout>
LayoutInflater inflater = LayoutInflater.from(this);

View view = inflater.inflate(R.layout.tabicon, null); final TextView txtCount = (TextView) view.findViewById(R.id.txtCount); spec = tabHost.newTabSpec("artists").setIndicator(view).setContent(intent);

更多相关文章

  1. 浅谈Java中Collections.sort对List排序的两种方法
  2. python list.sort()根据多个关键字排序的方法实现
  3. Android(安卓)开启或关闭WIFI实现
  4. android页面管理器。可以实现完整退出android软件
  5. Android(安卓)实现闪屏页和右上角的倒计时跳转
  6. 在Android中实现多线程同步
  7. libGDX引擎在android APP开发中应用系列-结合android原生app与lib
  8. Android(安卓)调用系统的分享[完美实现同时分享图片和文字]
  9. Android: How to Capture Screen in Gingerbread(2.3中实现截屏)

随机推荐

  1. Android 开发 调用图库选择图片实现和参
  2. [Android开发实战]Android手势密码(支付宝
  3. android 自定义控件学习之三 控件布局常
  4. android 如何把apk放进系统------unyaffs
  5. Android(安卓)EditText remove focus 只
  6. ANDROID 应用退出
  7. Android中的跨进程通信方法实例及特点分
  8. 定制你自己的Andoird桌面Launcher
  9. android在EditText中插入表情图片
  10. Android中Uri的使用