Rei*_*erd 6 android android-layout
我正在尝试执行以下操作:

现在,我正在尝试使用 NativeAndroid。
但是,我可以使用HTML 和 css来做到这一点。
如您所见,它类似于:
但是,如果我将背景设置为灰色并将文本设置为透明,则文本“消失”并且全部显示为灰色。
这是我的尝试(原生 Android):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff000000" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffcecece"
android:padding="5dp"
android:text="@string/hello_world"
android:textColor="#00ffffff" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
但是,它显示以下内容:

有文字,因为它是透明的,所以没有显示。
所以我的问题是:
谢谢!!
编辑: 那个蓝色背景必须是动态的,它可能是一个图像!
小智 3
你可以使用 Canvas 来实现:
Bitmap bmOverlay = Bitmap.createBitmap(1200, 1200, Bitmap.Config.ARGB_8888);//bMap.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawColor(Color.LTGRAY);
Paint paint = new Paint();
Paint mPaintText = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaintText.setStrokeWidth(3);
mPaintText.setStyle(Paint.Style.FILL_AND_STROKE);
mPaintText.setColor(Color.TRANSPARENT);
mPaintText.setTextSize(50f);
mPaintText.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
canvas.drawText("Your TExt", x, y, mPaintText);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4559 次 |
| 最近记录: |