GET*_*Tah 18
怎么样的:
Bitmap bitmap = ... // Load your bitmap here
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setTextSize(10);
canvas.drawText("Some Text here", x, y, paint);
Run Code Online (Sandbox Code Playgroud)
您不需要使用图形.
一种更简单的方法是创建一个FrameLayout带有两个元素 - ImageView用于图像,另一个视图用于您想要在顶部绘制的任何内容.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
当然,图像顶部的东西不需要是简单的TextView,它可以是另一个图像,或者包含你喜欢的任意元素的另一个布局.
| 归档时间: |
|
| 查看次数: |
20177 次 |
| 最近记录: |