【发布时间】:2018-01-31 13:56:00
【问题描述】:
我有一个使用颜色的布局,并将其不透明度设置为 0.2。我在该布局中有一个 textview,但是当我指定布局的不透明度较低时,Textview 文本也消失了。为什么呢?我只想淡化背景颜色而不是 textview 的文本。
//布局代码
<?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:alpha="0.2"
android:background="@drawable/background_rounded_black"
android:padding="@dimen/dp10">
<TextView
android:id="@+id/txtNews"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="1"
android:text="djfhwhfirhfiohrhvfuhvfjvbv vknfjvnfjv fv vefjkhvfhvv hvufevhfuievefv ivfhiefhvfe ifvjioefv"
android:textColor="@android:color/white"
android:textSize="@dimen/dp15" />
<TextView
android:id="@+id/txtTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/txtNews"
android:layout_marginTop="@dimen/dp10"
android:alpha="1"
android:drawableLeft="@drawable/clock_news"
android:text="12 hrs ago"
android:textColor="@android:color/white"
android:textSize="@dimen/dp15" />
现在看起来如何http://prntscr.com/gbxi87
【问题讨论】:
-
使用带有字母代码的背景颜色
标签: android android-linearlayout textview opacity android-relativelayout