>  Q&A  >  본문

android - TextView 如何设置半透明背景色?如图的效果。

如何 我想实现,字体下面的半透明背景, 不会遮住图片。 请问怎么处理呢?
我已经设置了如下的值( android:background="#e0000000"),但实现的效果, 确实黑色的背景,遮住了图片。

<TextView
        android:id="@+id/itemName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/app_name"
        android:textColor="@color/defaultWhite"
        android:textSize="16sp"
        android:background="#e0000000"
        android:layout_gravity="bottom" />
        
        
伊谢尔伦伊谢尔伦2718일 전573

모든 응답(2)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-17 14:36:43

    android:alpha="0.5"

    参考 View.html#attr_android:alpha

    alpha property of the view, as a value between 0 (completely transparent) and 1 (completely opaque).
    Related Methods: setAlpha(float)

    请善用developer.android.com

    회신하다
    0
  • 怪我咯

    怪我咯2017-04-17 14:36:43

    <TextView
    ...
    background="#99000000"
    style="@style/Transparent"
    ...
    </TextView>

    <style name="Transparent" parent="AppTheme">

        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowAnimationStyle">@null</item>
        <item name="android:windowNoTitle">true</item>

    </style>

    회신하다
    0
  • 취소회신하다