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

 

Java代码   收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.     xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle">  
  4.   "20dp"  />      
  5.   "#ff2233" />  
  6.   

 

 

Java代码   收藏代码
  1. res/layout/tabicon.xml  
  2.   
  3.     android:orientation="vertical"  
  4.     android:background="@null"  
  5.     android:id="@+id/rlayout"  
  6.     android:layout_width="wrap_content"  
  7.     android:layout_height="wrap_content" >  
  8.     
  9.             android:id="@+id/icon"  
  10.             android:src="@android:drawable/ic_menu_mylocation"   
  11.             android:layout_margin="0dp"  
  12.             android:layout_height="wrap_content"   
  13.             android:layout_width="wrap_content"/>  
  14.   
  15.     "wrap_content" android:layout_height="wrap_content"  
  16.         android:text="50" android:textSize="12dp" android:textStyle="bold"    
  17.         android:background="@drawable/shapecount"  
  18.         android:textColor="#FFFFFF"  
  19.         android:paddingLeft="3dp" android:paddingRight="3dp"  
  20.             android:layout_margin="0dp"  
  21.         android:layout_alignBottom="@+id/rlayout"  
  22.         android:id="@+id/txtCount" />  
  23.   
  24.  


     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多项目依赖在Eclipse中无法关联源代码的问题解决 (an
  2. Android 7.1 触摸事件代码跟踪
  3. android 开发中将十六进制 颜色代码 转换为int类型数值 方法 :
  4. TextView --- 内容设置成上下滑动 和 代码设置字体颜色
  5. android微博客户端源代码
  6. Android 登录界面xml代码
  7. android 正三角,倒三角的实现代码
  8. Android上积累代码
  9. Android实用代码

随机推荐

  1. Code First for Mysql 错误:未为提供程序
  2. sql语句,order by后加参数问题
  3. mybatis中 insert into select 批量生成u
  4. ORA-19909:当进行不完全恢复之后使用open
  5. sql 2005判断某个表或某个表中的列是否存
  6. MySQL中的类Decode用法
  7. 如何优化用于从表复制数据的oracle过程?
  8. SQL关键字转换大写核心算法实现
  9. 关于使用框架操作Oracle数据库切换MySQL
  10. SQLServer 延迟事务持久性