Java 透明编辑文本Android Studio
我正在尝试使我的android studio项目中的Java 透明编辑文本Android Studio,java,android,xml,android-studio,android-layout,Java,Android,Xml,Android Studio,Android Layout,我正在尝试使我的android studio项目中的EditText透明化。我希望它看起来像这里的编辑文本 但是,即使我尝试过使用transparent和ffffff这两种方法,我的也不是这样的。有人能帮我一下吗?我希望我的编辑文本背景看起来像我显示的图像中的背景。 <EditText android:layout_width="match_parent" android:layout_margin="32dp" android:layout
EditText
透明化。我希望它看起来像这里的编辑文本
但是,即使我尝试过使用transparent
和ffffff
这两种方法,我的也不是这样的。有人能帮我一下吗?我希望我的编辑文本背景看起来像我显示的图像中的背景。
<EditText
android:layout_width="match_parent"
android:layout_margin="32dp"
android:layout_height="wrap_content"
android:hint="Username"
android:padding="16dp"
android:background="@drawable/edittext_bg" />
drawables文件夹中的edittext_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#80ffffff" />
<corners android:radius="5dp" />
</shape>
更改
的颜色值以调整透明度 添加background
属性以设置edittext背景,如下所示android:background=“@drawable/edit\u bg”
尝试此代码
编辑_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="#E288CB"/>
<corners
android:radius="5dp"/>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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="#C71D8B"
android:gravity="center"
tools:context=".TransparentEditActivtiy">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:orientation="vertical">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_bg"
android:hint="Enter Name"
android:padding="15dp"
android:textColor="#fff"
android:textColorHint="#fff" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_bg"
android:hint="Enter Password"
android:padding="15dp"
android:textColor="#fff"
android:textColorHint="#fff"
android:layout_marginTop="20dp"/>
</LinearLayout>
可能重复,因为这是不透明的。完全透明不会有磨砂的外观。它是部分透明的,用字母表示一些白色。您可能需要一个介于FF和00之间的alpha字节(可能更接近00)。