EditText背景颜色不透明度android

时间:2017-09-19 17:38:26

标签: java android

我正在让用户更改编辑textview的背景颜色。我想让用户有机会设置颜色的不透明度。我的编辑文本XML代码如下所示

<EditText
    android:id="@+id/text_quotes"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/transparent"
    android:gravity="center"
    android:textStyle="bold"
    android:textColor="?attr/colorPrimaryDark"
    android:shadowRadius="0"
    android:text="Text" 
    android:textCursorDrawable="@null"
    android:textSize="@dimen/newMainText" />

如果有人想要设置此视图的更改背景颜色的不透明度,请告诉我。非常感谢!

1 个答案:

答案 0 :(得分:2)

您可以尝试使用此Alpha,它会以编程方式为您提供不透明度

youredittext.getBackground().setAlpha(45);