Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.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
Android 如何在EditText中设置浮动文本?_Android_Xml_Android Edittext_Android Studio 2.3 - Fatal编程技术网

Android 如何在EditText中设置浮动文本?

Android 如何在EditText中设置浮动文本?,android,xml,android-edittext,android-studio-2.3,Android,Xml,Android Edittext,Android Studio 2.3,在我的应用程序注册页面中,在此处编辑文本。在这个编辑文本中,我想显示浮动文本。但我尝试了下面的代码,但不起作用。任何人请告诉我 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools=

在我的应用程序注册页面中,在此处编辑文本。在这个编辑文本中,我想显示浮动文本。但我尝试了下面的代码,但不起作用。任何人请告诉我

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
 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"
 tools:context="com.citrin.popeye.dev.popeye.Registration">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/signupttl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="25dp"
        android:text="Register"
        android:textSize="24dp"
        android:layout_weight="1"
        android:textColor="#000000"/>
    <TextView
        android:id="@+id/signupttl1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="6dp"
        android:text="Sign up to create an account."
        android:textSize="15dp"
        android:layout_weight="1"/>

    <android.support.design.widget.TextInputLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textColorHint="#BDBDBD"
        android:layout_weight="1">
        <EditText
            android:id="@+id/name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="38dp"
            android:drawablePadding="20dp"
            android:textSize="16dp"
            android:drawableLeft="@drawable/ic_name"
            android:inputType="textCapSentences"
            android:hint="Name"
            android:nextFocusDown="@+id/email"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textColorHint="#BDBDBD"
        android:layout_weight="1">
        <EditText
            android:id="@+id/email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="16dp"
            android:drawableLeft="@drawable/ic_email"
            android:drawablePadding="20dp"
            android:hint="Email ID"
            android:inputType="textEmailAddress"
            android:nextFocusDown="@+id/nation"
            android:textSize="16dp" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textColorHint="#BDBDBD"
        android:layout_weight="1">
        <EditText
            android:id="@+id/nation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:drawableLeft="@drawable/ic_flag"
            android:layout_marginTop="16dp"
            android:drawablePadding="20dp"
            android:textSize="16dp"
            android:inputType="textCapWords"
            android:hint="Nationality"
            android:nextFocusDown="@+id/cor"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textColorHint="#BDBDBD"
        android:layout_weight="1">
        <EditText
            android:id="@+id/cor"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:drawableLeft="@drawable/ic_country"
            android:layout_marginTop="16dp"
            android:inputType="textCapWords"
            android:textSize="16dp"
            android:drawablePadding="20dp"
            android:hint="Country of Residence"
            android:nextFocusDown="@+id/pass"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:textColorHint="#BDBDBD"
        android:layout_weight="1">
        <EditText
            android:id="@+id/pass"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawablePadding="20dp"
            android:layout_gravity="center"
            android:drawableLeft="@drawable/ic_pass"
            android:layout_marginTop="16dp"
            android:inputType="numberPassword"
            android:textSize="16dp"
            android:maxLength="4"
            android:hint="Digital Secure Key password"
            android:nextFocusDown="@+id/signup"/>
    </android.support.design.widget.TextInputLayout>

    <Button
        android:id="@+id/signup"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="40dp"
        android:text="SIGN UP"
        android:layout_weight="1"
        android:textColor="#FFFFFF"
        android:background="@drawable/btn"
        android:layout_marginBottom="15dp"
        android:onClick="onSignUpClick"/>

</LinearLayout>

</ScrollView>


我认为您错过了gradle文件依赖项,请检查设计依赖项。这是我的工作

 compile 'com.android.support:design:xx.x.x' 

我认为您错过了gradle文件依赖项,请检查设计依赖项。这是我的工作

 compile 'com.android.support:design:xx.x.x' 
在build.gradle文件中


在build.gradle文件中

在build.gradle(模块:app)中添加此依赖项

编译'com.android.support:design:25.2.0'

使用您的支持库版本更改25.2.0


我希望这对你有帮助

在build.gradle(模块:app)中添加此依赖项

编译'com.android.support:design:25.2.0'

使用您的支持库版本更改25.2.0


我希望这对你有帮助

我认为您应该添加这两个依赖项

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'

我认为你应该加上这两个依赖项

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'

您是否为相同的应用程序添加了设计渐变依赖项?我使用这个android.support.design.widget.TextInputLayout添加了设计渐变依赖项。你那边的问题是什么?您得到的错误是什么?您是否为相同的错误添加了design gradle依赖项?我使用这个android.support.design.widget.TextInputLayout完成了此操作。你那边的问题是什么?您遇到的错误是什么?支持库的最新版本是什么?请检查此链接以获取最新的库更新支持库的最新版本是什么?请检查此链接以获取最新的库更新