Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 透明编辑文本Android Studio_Java_Android_Xml_Android Studio_Android Layout - Fatal编程技术网

Java 透明编辑文本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

我正在尝试使我的android studio项目中的
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)。