好多人问怎么实现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. Android异步处理四:AsyncTask的实现原理 .
  2. android 相对定位布局方向 RelativeLayout
  3. 《Android面试宝典》学习笔记(第二章:布局)
  4. RelativeLayout相对布局实验
  5. android布局相关属性
  6. 【学习笔记】Android常用布局
  7. Android 面试总结之布局常见问题
  8. RelativeLayout布局及属性

随机推荐

  1. android 解决getNetworkInfo过时
  2. android-包签名
  3. Flutter Android 端热修复(热更新)实践
  4. Android(安卓)关于蓝牙的文章
  5. android 显示单选列表对话框 builder.set
  6. Android之网络请求5————OkHttp源码2:
  7. Android中 AsyncTask的使用
  8. Android 40个面试点
  9. android的5种数据存储方式
  10. Android存储选项简析