gpt4 book ai didi

android - 在 Android 中将文字覆盖在图像上

转载 作者:行者123 更新时间:2023-11-30 00:59:21 27 4
gpt4 key购买 nike

这是我的布局,我试图在图像上写文字。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:background="?android:attr/selectableItemBackground"
android:padding="@dimen/tile_padding">

<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="@dimen/tile_height"
android:scaleType="fitXY"
/>

<ImageView
android:layout_width="match_parent"
android:layout_height="160dp"
android:alpha="0.30"
android:background="@color/dark_grey"
/>

<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/tile_height"
android:layout_gravity="center"
android:gravity="bottom|end"
android:textColor="@color/white"
android:textSize="22sp"
/>


</RelativeLayout>

为了使文本在图像上可见,我在原始图像上绘制了更多图像,alpha = 0.30。

我想在原始图像上不完全绘制其他图像,而只是绘制文本的部分。

最佳答案

试试下面的布局

<?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="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:padding="@dimen/tile_padding">

<ImageView
android:id="@+id/thumbnail"
android:layout_width="match_parent"
android:layout_height="@dimen/tile_height"
android:scaleType="fitXY" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.30"
android:background="@color/dark_grey"
android:gravity="bottom|end">

<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="@dimen/tile_height"
android:layout_gravity="center"
android:textColor="@color/white"
android:textSize="22sp" />
</LinearLayout>
</FrameLayout>

关于android - 在 Android 中将文字覆盖在图像上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39667132/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com