启用提示但不显示,光标也不会显示为用户输入命名密码

时间:2018-02-07 04:51:27

标签: android xml

再次抱歉发布此问题,但之前没有给我任何答案。所以我的困境是我无法在登录之间创建一条线,我也无法显示我的提示电子邮件。我还希望用户能够输入,因为他们看到光标在填充电子邮件和密码时闪烁。

这就是我想要实现的目标

enter image description here

这是我的整个Xml,我知道这是本地的,但我会感谢任何指导和步骤。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:fitsSystemWindows="true"
    android:background="@drawable/background_normal">


    <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"

        <android.support.design.widget.TextInputLayout
            android:layout_width="304dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="0dp"
            android:layout_marginTop="2dp"
            android:background="@color/white"
            app:hintEnabled="true"
            >

            <EditText
                android:id="@+id/email"
                android:layout_width="match_parent"
                android:layout_height="38dp"
                android:layout_marginBottom="0dp"
                android:background="@color/white"
                android:fontFamily="@font/raleway"
                android:hint="Email"
                android:inputType="textEmailAddress"
                android:textColor="@color/black"
                android:textColorHint="@color/black" />

        </android.support.design.widget.TextInputLayout>

        <!--  Password Label -->
        <android.support.design.widget.TextInputLayout
            android:layout_width="304dp"
            android:layout_height="wrap_content"
            android:layout_marginBottom="6dp"
            android:layout_marginTop="0dp"
            android:background="@color/white">

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="38dp"
                android:layout_marginTop="0dp"
                android:background="@color/white"
                android:fontFamily="@font/raleway"
                android:hint="Password"
                android:inputType="textPassword"
                android:textColor="@color/black"
                android:textColorHint="@color/black" />
        </android.support.design.widget.TextInputLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="0dp"
            android:paddingLeft="55dp"
            android:paddingRight="24dp">

            <android.support.v7.widget.AppCompatButton
                android:id="@+id/login"
                android:layout_width="175dp"
                android:layout_height="35dp"
                android:background="@color/white"
                android:fontFamily="@font/raleway"
                android:gravity="center"
                android:text="@string/logintoproceed"
                android:textColor="@color/black"
                android:textSize="12sp" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingTop="24dp">

            <TextView
                android:id="@+id/signup"
                android:layout_width="165dp"
                android:layout_height="42dp"
                android:layout_marginBottom="24dp"
                android:fontFamily="@font/raleway"
                android:text="@string/create"
                android:textSize="16dip" />

            <TextView
                android:id="@+id/forgotpass"
                android:layout_width="165dp"
                android:layout_height="42dp"
                android:layout_marginBottom="24dp"
                android:fontFamily="@font/raleway"
                android:text="@string/forgotpassword"
                android:textSize="16dip" />

        </LinearLayout>



    </LinearLayout>
</ScrollView>
</RelativeLayout>

4 个答案:

答案 0 :(得分:2)

我认为您的背景颜色会覆盖提示文本颜色。尝试为提示文字提供强调色。

答案 1 :(得分:2)

尝试在TextInputLayout中提供textcolorhint

       <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="30dp"
        android:layout_marginTop="30dp"
        android:textColorHint="@color/grey"
        android:theme="@style/MyMaterialTheme"
        app:hintTextAppearance="@android:style/TextAppearance.Small">
        <EditText
            android:id="@+id/signup_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:backgroundTint="@color/grey"
            android:hint="@string/email_id"
            android:inputType="textEmailAddress"
            android:textColor="@color/grey"
            />
         </android.support.design.widget.TextInputLayout>

答案 2 :(得分:0)

使用

 <style name="TextLabel" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:textColor">@color/secondary_text</item>
    <item name="colorControlHighlight">@color/secondary_text</item>
    <item name="colorControlNormal">@color/secondary_text</item>
    <item name="colorControlActivated">@android:color/black</item>
    <item name="android:textColorHint">@color/secondary_text</item>
</style>

在xml中应用主题

   <android.support.design.widget.TextInputLayout
    android:theme="@style/TextLabel"

答案 3 :(得分:0)

使用TextInputLayout作为提示颜色,并应用材质主题。

<android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"            
        android:layout_margin="10dp"
        android:textColorHint="@color/grey"
        android:theme="@style/MyMaterialTheme"
        app:hintTextAppearance="@android:style/TextAppearance.Small">

        <EditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:backgroundTint="@color/grey"
            android:hint="@string/email"
            android:inputType="textEmailAddress"
            android:textColor="@color/blach"/>

         </android.support.design.widget.TextInputLayout>

希望它能帮到你!!