目前看来有三种方法可以实现

1. framelayout, a framelayout is used to stack a TextView on top of an ImageView

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent">    <ImageView          android:layout_width="fill_parent"         android:layout_height="fill_parent"             android:scaleType="center"        android:src="@drawable/golden_gate" />        <TextView        android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_marginBottom="20dip"        android:layout_gravity="center_horizontal|bottom"        android:padding="12dip"                android:background="#AA000000"        android:textColor="#ffffffff"                android:text="Golden Gate" /></FrameLayout>

2. TextView on Canvas。 和framelayout不同,Canvas不是继承自ViewGroup,它不可以添加child views,所以你需要使用drawBitmap和drawText方法去实现

3. 使用merge tag,方法大致和framelayout一样

<?xml version="1.0" encoding="utf-8"?><!--<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    >--><merge xmlns:android="http://schemas.android.com/apk/res/android">    <ImageView          android:layout_width="fill_parent"         android:layout_height="fill_parent"             android:scaleType="center"        android:src="@drawable/mini" />        <TextView        android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_gravity="center"        android:padding="12dip"        android:textSize="20sp"        android:textStyle="bold"        android:textColor="#ffff0000"                android:text="Mini-Countryman" /></merge><!--</LinearLayout>-->

具体与framelayout区别参考 http://developer.android.com/resources/articles/layout-tricks-merge.html

更多相关文章

  1. android屏幕自适应4方法案例整合
  2. 打开SDK Manager检查Android SDK下载和更新失败的解决方法
  3. android studio 3.6.0 绑定视图新特性的方法
  4. androidSDK无法更新的解决方法之一
  5. android全屏去掉title栏的多种实现方法
  6. View类的XML属性、相关方法及说明
  7. android 中隐藏EditText的下划线方法
  8. Android调用系统默认浏览器访问的方法
  9. android Uri获取真实路径转换成File的方法

随机推荐

  1. 谁在关心toString的性能?
  2. Monadic Function_Haskell笔记12
  3. 从JDK中,我们能学到哪些设计模式?
  4. 为什么这段代码输出的是 ”Hello World”
  5. 10 行 Java 代码实现最近被使用(LRU)缓存
  6. 在 Java 中正确使用注释
  7. Java 并发的四种风味:Thread、Executor、F
  8. 一个NullPointerException,竟然有这么多花
  9. 减少 GC 开销的 5 个编码技巧
  10. 原创 | 老生常谈,TCP为啥要三次握手?