【问题标题】:Android: Non-transparent text on transparent imageAndroid:透明图像上的非透明文本
【发布时间】:2023-04-11 12:14:01
【问题描述】:

我需要在透明图像上放置文字,但我的文字也变得透明了。

更新:我有一个 Activity 背景,它是一张图片,而不是我的 LinearLayout,背景是透明图片,在该布局中,我需要一个 TextView,其文本不透明。

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img_background"
android:fitsSystemWindows="true"
tools:context="team.com.ContactUsActivity">
>
<LinearLayout
    android:id="@+id/linearLayoutContactUsData"
    android:layout_width="match_parent"
    android:layout_height="200dip"
    android:background="@drawable/img_contact_us"
    android:alpha="0.4"
    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textColor="#FFFFFF"
        android:textSize="18dip"
        android:text="Phone: 111-111-111"
        />
</LinearLayout>

有什么建议吗?

【问题讨论】:

  • 将 TextView 上的 Alpha 设置为 1
  • 我试过了,但它不起作用。我仍然得到透明文本。

标签: android image text transparent


【解决方案1】:

只需删除android:alpha
如果不这样做,TextView 将继承容器属性,导致它是透明的,而不是完全可见的。

TextView 背景默认是透明的。

【讨论】:

  • 是的,但是我有一个 Activity 背景,它是一张图片,而不是我的 LinearLayout,背景是透明图片,在那个布局中,我需要一个 TextView,其文本不透明。
  • 布局是透明的,除非您没有为其设置背景图片。让透明度属于图片,不属于布局!你应该知道 PNG 文件确实有一个 alpha 通道
  • 应该可以。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-22
  • 2014-07-21
  • 2010-12-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多