我正在尝试使用Material Design中的EditText,并且我遇到了运行时异常。

huangapple go评论62阅读模式
英文:

I'm trying to use EditText from Material Design - and I'm getting runtime exception

问题

I'm trying to use EditText from Material Design (https://material.io/develop/android/components/text-fields/) and I'm getting a runtime exception.

I want to solve this problem

EditText Problem: When I try to open the app with a regular EditText on a monitor, the app crashes [closed]

This is part of the run log:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fares.orderfood/com.fares.orderfood.SignInActivity}: java.lang.ClassCastException: com.google.android.material.textfield.TextInputLayout cannot be cast to android.widget.EditText

    at com.fares.orderfood.SignInActivity.onCreate(SignInActivity.java:33)
/full

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fares.orderfood, PID: 5512
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fares.orderfood/com.fares.orderfood.SignInActivity}: java.lang.ClassCastException: com.google.android.material.textfield.TextInputLayout cannot be cast to android.widget.EditText
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 Caused by: java.lang.ClassCastException: com.google.android.material.textfield.TextInputLayout cannot be cast to android.widget.EditText
    at com.fares.orderfood.SignInActivity.onCreate(SignInActivity.java:34)
    at android.app.Activity.performCreate(Activity.java:7009)

My Java line 33:

edtName = (EditText) findViewById(R.id.edtName);

My Java file full:

import androidx.appcompat.app.AppCompatActivity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.fares.orderfood.model.User;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;

public class SignInActivity extends AppCompatActivity {

    EditText edtName, edtphone, edtpassword;
    Button signinbtn1, cancel1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);

        // Text Input
        edtName = (EditText) findViewById(R.id.edtName); // this line (33)
        edtpassword = (EditText) findViewById(R.id.edtpassword);
        edtphone = (EditText) findViewById(R.id.edtphone);
    }
}

My style file:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

    <item name="colorControlActivated">@color/colorPrimary</item>

    <item name="textAppearanceHeadline1">@style/TextAppearance.MaterialComponents.Headline1</item>
    <item name="textAppearanceHeadline2">@style/TextAppearance.MaterialComponents.Headline2</item>
    <item name="textAppearanceHeadline3">@style/TextAppearance.MaterialComponents.Headline3</item>
    <item name="textAppearanceHeadline4">@style/TextAppearance.MaterialComponents.Headline4</item>
    <item name="textAppearanceHeadline5">@style/TextAppearance.MaterialComponents.Headline5</item>
    <item name="textAppearanceHeadline6">@style/TextAppearance.MaterialComponents.Headline6</item>
    <item name="textAppearanceSubtitle1">@style/TextAppearance.MaterialComponents.Subtitle1</item>
    <item name="textAppearanceSubtitle2">@style/TextAppearance.MaterialComponents.Subtitle2</item>
    <item name="textAppearanceBody1">@style/TextAppearance.MaterialComponents.Body1</item>
    <item name="textAppearanceBody2">@style/TextAppearance.MaterialComponents.Body2</item>
    <item name="textAppearanceCaption">@style/TextAppearance.MaterialComponents.Caption</item>
    <item name="textAppearanceButton">@style/TextAppearance.MaterialComponents.Button</item>
    <item name="textAppearanceOverline">@style/TextAppearance.MaterialComponents.Overline</item>
    <!--  // Library material.io/design // -->
</style>

Add my new XML:

<?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"
    android:background="@color/loginPageBackgroundColor"
    tools:context=".SignInActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:orientation="vertical"
        android:padding="24dp"
        android:paddingTop="16dp">

        <ImageView
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="48dp"
            android:layout_marginBottom="16dp"
            app:srcCompat="@drawable/store"
            tools:ignore="VectorDrawableCompat" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="122dp"
            android:text="@string/signin"
            android:textSize="50sp"
            android:textStyle="bold" />

        <!-- input Username -->
        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/edtName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_name">
            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="text"
                android:maxLines="1"
                android:text="fares" />
        </com.google.android.material.textfield.TextInputLayout>
        <!-- input Username -->
        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/edtphone"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_phone">
            <com.google.android.material.textfield.TextInputEditText
                android:layout_width

<details>
<summary>英文:</summary>

I&#39;m trying to use EditText from Material Design ( https://material.io/develop/android/components/text-fields/ ) and I&#39;m getting runtime exception.


I want to solve this problem

EditText Problem : When i try to open app with a regular EditText in a monitor and the app Crash [closed]

This&#39;s part of run log:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fares.orderfood/com.fares.orderfood.SignInActivity}: java.lang.ClassCastException: com.google.android.material.textfield.TextInputLayout cannot be cast to android.widget.EditText
    
        at com.fares.orderfood.SignInActivity.onCreate(SignInActivity.java:33)
/full

        E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.fares.orderfood, PID: 5512
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fares.orderfood/com.fares.orderfood.SignInActivity}: java.lang.ClassCastException: com.google.android.material.textfield.TextInputLayout cannot be cast to android.widget.EditText
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.ClassCastException: com.google.android.material.textfield.TextInputLayout cannot be cast to android.widget.EditText
        at com.fares.orderfood.SignInActivity.onCreate(SignInActivity.java:34)
        at android.app.Activity.performCreate(Activity.java:7009)

my java line 33

    edtName =(EditText)findViewById(R.id.edtName);


My java file full:

    import androidx.appcompat.app.AppCompatActivity;

    import android.app.ProgressDialog;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;
    
    import com.fares.orderfood.model.User;
    import com.google.firebase.database.DataSnapshot;
    import com.google.firebase.database.DatabaseError;
    import com.google.firebase.database.DatabaseReference;
    import com.google.firebase.database.FirebaseDatabase;
    import com.google.firebase.database.ValueEventListener;
    
    public
    class SignInActivity extends AppCompatActivity {

    EditText edtName, edtphone,edtpassword;
    Button signinbtn1,cancel1;

    @Override
    protected
    void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);

    ////////////////Text Input///////////////////
        edtName =(EditText)findViewById(R.id.edtName);     /// this line (33)

        edtpassword = (EditText)findViewById(R.id.edtpassword);
        edtphone = (EditText)findViewById(R.id.edtphone);



my style file

    &lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.MaterialComponents.Light.NoActionBar&quot;&gt;
            &lt;!-- Customize your theme here. --&gt;
            &lt;item name=&quot;colorPrimary&quot;&gt;@color/colorPrimary&lt;/item&gt;
            &lt;item name=&quot;colorPrimaryDark&quot;&gt;@color/colorPrimaryDark&lt;/item&gt;
            &lt;item name=&quot;colorAccent&quot;&gt;@color/colorAccent&lt;/item&gt;
    
    &lt;item name=&quot;colorControlActivated&quot;&gt;@color/colorPrimary&lt;/item&gt;
    
                 &lt;item name=&quot;textAppearanceHeadline1&quot;&gt;@style/TextAppearance.MaterialComponents.Headline1&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceHeadline2&quot;&gt;@style/TextAppearance.MaterialComponents.Headline2&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceHeadline3&quot;&gt;@style/TextAppearance.MaterialComponents.Headline3&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceHeadline4&quot;&gt;@style/TextAppearance.MaterialComponents.Headline4&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceHeadline5&quot;&gt;@style/TextAppearance.MaterialComponents.Headline5&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceHeadline6&quot;&gt;@style/TextAppearance.MaterialComponents.Headline6&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceSubtitle1&quot;&gt;@style/TextAppearance.MaterialComponents.Subtitle1&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceSubtitle2&quot;&gt;@style/TextAppearance.MaterialComponents.Subtitle2&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceBody1&quot;&gt;@style/TextAppearance.MaterialComponents.Body1&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceBody2&quot;&gt;@style/TextAppearance.MaterialComponents.Body2&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceCaption&quot;&gt;@style/TextAppearance.MaterialComponents.Caption&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceButton&quot;&gt;@style/TextAppearance.MaterialComponents.Button&lt;/item&gt;
                 &lt;item name=&quot;textAppearanceOverline&quot;&gt;@style/TextAppearance.MaterialComponents.Overline&lt;/item&gt;
             &lt;!--  // Librarty material.io/design // --&gt;
    
        &lt;/style&gt;


add new my xml 
this my xml 

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
    &lt;ScrollView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    android:background=&quot;@color/loginPageBackgroundColor&quot;
        tools:context=&quot;.SignInActivity&quot;&gt;
    
        &lt;LinearLayout
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:clipChildren=&quot;false&quot;
            android:clipToPadding=&quot;false&quot;
            android:orientation=&quot;vertical&quot;
            android:padding=&quot;24dp&quot;
            android:paddingTop=&quot;16dp&quot;&gt;
    
            &lt;ImageView
                android:layout_width=&quot;64dp&quot;
                android:layout_height=&quot;64dp&quot;
                android:layout_gravity=&quot;center_horizontal&quot;
                android:layout_marginTop=&quot;48dp&quot;
                android:layout_marginBottom=&quot;16dp&quot;
                app:srcCompat=&quot;@drawable/store&quot;
                tools:ignore=&quot;VectorDrawableCompat&quot; /&gt;
    
            &lt;TextView
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:layout_gravity=&quot;center_horizontal&quot;
                android:layout_marginBottom=&quot;122dp&quot;
                android:text=&quot;@string/signin&quot;
                android:textSize=&quot;50sp&quot;
                android:textStyle=&quot;bold&quot; /&gt;
    
        &lt;!-- input Username  --&gt;
            &lt;com.google.android.material.textfield.TextInputLayout
                android:id=&quot;@+id/edtName&quot;
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:hint=&quot;@string/hint_name&quot;&gt;
                    &lt;com.google.android.material.textfield.TextInputEditText
                        android:layout_width=&quot;match_parent&quot;
                        android:layout_height=&quot;wrap_content&quot;
                        android:inputType=&quot;text&quot;
                        android:maxLines=&quot;1&quot;
                        android:text=&quot;fares&quot;/&gt;
            &lt;/com.google.android.material.textfield.TextInputLayout&gt;
            &lt;!-- input Username  --&gt;
            &lt;com.google.android.material.textfield.TextInputLayout
                android:id=&quot;@+id/edtphone&quot;
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:hint=&quot;@string/hint_phone&quot;&gt;
                &lt;com.google.android.material.textfield.TextInputEditText
                    android:layout_width=&quot;match_parent&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:inputType=&quot;phone&quot;
                    android:maxLines=&quot;1&quot;
                    android:text=&quot;0988123344&quot;/&gt;
            &lt;/com.google.android.material.textfield.TextInputLayout&gt;
    
        &lt;!-- input Password  --&gt;
            &lt;com.google.android.material.textfield.TextInputLayout
                android:id=&quot;@+id/edtpassword&quot;
                android:layout_width=&quot;match_parent&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:hint=&quot;@string/hint_password&quot;
                app:errorEnabled=&quot;true&quot;
                app:endIconMode=&quot;password_toggle&quot;&gt;
                &lt;com.google.android.material.textfield.TextInputEditText
                    android:layout_width=&quot;match_parent&quot;
                    android:layout_height=&quot;wrap_content&quot;
                    android:inputType=&quot;textPassword&quot;
                    android:text=&quot;1234&quot;/&gt;
            &lt;/com.google.android.material.textfield.TextInputLayout&gt;
    
    
        &lt;!-- input Button  --&gt;
        &lt;RelativeLayout
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;wrap_content&quot;&gt;
    
            &lt;!-- input Button signin --&gt;
            &lt;com.google.android.material.button.MaterialButton
                android:id=&quot;@+id/signbtn&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot;
                android:layout_alignParentEnd=&quot;true&quot;
                android:layout_alignParentRight=&quot;true&quot;
                android:text=&quot;@string/signin&quot;
                app:backgroundTint=&quot;#A8A8A8&quot;/&gt;
    
            &lt;!-- input Button cancel --&gt;
            &lt;com.google.android.material.button.MaterialButton
            android:id=&quot;@+id/cancel_button&quot;
            style=&quot;@style/Widget.MaterialComponents.Button.TextButton&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_marginEnd=&quot;12dp&quot;
            android:layout_marginRight=&quot;12dp&quot;
    
            android:layout_toStartOf=&quot;@+id/signbtn&quot;
            android:layout_toLeftOf=&quot;@+id/signbtn&quot;
            android:text=&quot;@string/text_cancel&quot; /&gt;
        &lt;/RelativeLayout&gt;
    
    
    
        &lt;/LinearLayout&gt;
    
    &lt;/ScrollView&gt;



Please, I need help

</details>


# 答案1
**得分**: 0

同样的错误:

您正在将TextInputLayout转换为EditText,这是不可能的。请尝试将TextInputEditText转换为EditText,这将解决您的问题。

我的Java代码:

```java
public class SignInActivity extends AppCompatActivity {

    TextInputEditText edtName, edtphone, edtpassword;
    Button signinbtn1, cancel1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);

        ////////////////文本输入///////////////////
        edtName = (TextInputEditText) findViewById(R.id.edtName);

        edtpassword = (TextInputEditText) findViewById(R.id.edtpassword);
        edtphone = (TextInputEditText) findViewById(R.id.edtphone);
    }
}

您需要像这样给TextInputEditText分配ID,而不是TextInputLayout。这将解决您的问题:

XML布局:

<?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"
    android:background="@color/loginPageBackgroundColor"
    tools:context=".SignInActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:orientation="vertical"
        android:padding="24dp"
        android:paddingTop="16dp">

        <ImageView
            android:layout_width="64dp"
            android:layout_height="64dp"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="48dp"
            android:layout_marginBottom="16dp"
            app:srcCompat="@drawable/store"
            tools:ignore="VectorDrawableCompat" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginBottom="122dp"
            android:text="@string/signin"
            android:textSize="50sp"
            android:textStyle="bold" />

        <!-- 输入用户名 -->
        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_name">
            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/edtName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="text"
                android:maxLines="1"
                android:text="fares" />
        </com.google.android.material.textfield.TextInputLayout>

        <!-- 输入手机号 -->
        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_phone">
            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/edtphone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="phone"
                android:maxLines="1"
                android:text="0988123344" />
        </com.google.android.material.textfield.TextInputLayout>

        <!-- 输入密码 -->
        <com.google.android.material.textfield.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/hint_password"
            app:errorEnabled="true"
            app:endIconMode="password_toggle">
            <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/edtpassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:text="1234" />
        </com.google.android.material.textfield.TextInputLayout>

        <!-- 输入按钮 -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <!-- 登录按钮 -->
            <com.google.android.material.button.MaterialButton
                android:id="@+id/signbtn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:text="@string/signin"
                app:backgroundTint="#A8A8A8" />

            <!-- 取消按钮 -->
            <com.google.android.material.button.MaterialButton
                android:id="@+id/cancel_button"
                style="@style/Widget.MaterialComponents.Button.TextButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="12dp"
                android:layout_marginRight="12dp"
                android:layout_toStartOf="@+id/signbtn"
                android:layout_toLeftOf="@+id/signbtn"
                android:text="@string/text_cancel" />
        </RelativeLayout>

    </LinearLayout>

</ScrollView>
英文:

Also the same error

You are casting TextInputLayout into EditText which is not possible, instead of this please try to cast TextInputEditText into EditText it will resolve your problem.

my java code

public
class SignInActivity extends AppCompatActivity {
TextInputEditText edtName, edtphone,edtpassword;
Button signinbtn1,cancel1;
@Override
protected
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in);
////////////////Text Input///////////////////
edtName =(TextInputEditText)findViewById(R.id.edtName);
edtpassword = (TextInputEditText)findViewById(R.id.edtpassword);
edtphone = (TextInputEditText)findViewById(R.id.edtphone);

You have to give the id to TextInputEditText like this instead of TextInputLayout. It will resolve your problem:

XML layout

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;ScrollView xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
xmlns:tools=&quot;http://schemas.android.com/tools&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;match_parent&quot;
android:background=&quot;@color/loginPageBackgroundColor&quot;
tools:context=&quot;.SignInActivity&quot;&gt;
&lt;LinearLayout
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:clipChildren=&quot;false&quot;
android:clipToPadding=&quot;false&quot;
android:orientation=&quot;vertical&quot;
android:padding=&quot;24dp&quot;
android:paddingTop=&quot;16dp&quot;&gt;
&lt;ImageView
android:layout_width=&quot;64dp&quot;
android:layout_height=&quot;64dp&quot;
android:layout_gravity=&quot;center_horizontal&quot;
android:layout_marginTop=&quot;48dp&quot;
android:layout_marginBottom=&quot;16dp&quot;
app:srcCompat=&quot;@drawable/store&quot;
tools:ignore=&quot;VectorDrawableCompat&quot; /&gt;
&lt;TextView
android:layout_width=&quot;wrap_content&quot;
android:layout_height=&quot;wrap_content&quot;
android:layout_gravity=&quot;center_horizontal&quot;
android:layout_marginBottom=&quot;122dp&quot;
android:text=&quot;@string/signin&quot;
android:textSize=&quot;50sp&quot;
android:textStyle=&quot;bold&quot; /&gt;
&lt;!-- input Username  --&gt;
&lt;com.google.android.material.textfield.TextInputLayout
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:hint=&quot;@string/hint_name&quot;&gt;
&lt;com.google.android.material.textfield.TextInputEditText
android:id=&quot;@+id/edtName&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:inputType=&quot;text&quot;
android:maxLines=&quot;1&quot;
android:text=&quot;fares&quot;/&gt;
&lt;/com.google.android.material.textfield.TextInputLayout&gt;
&lt;!-- input Username  --&gt;
&lt;com.google.android.material.textfield.TextInputLayout
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:hint=&quot;@string/hint_phone&quot;&gt;
&lt;com.google.android.material.textfield.TextInputEditText
android:id=&quot;@+id/edtphone&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:inputType=&quot;phone&quot;
android:maxLines=&quot;1&quot;
android:text=&quot;0988123344&quot;/&gt;
&lt;/com.google.android.material.textfield.TextInputLayout&gt;
&lt;!-- input Password  --&gt;
&lt;com.google.android.material.textfield.TextInputLayout
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:hint=&quot;@string/hint_password&quot;
app:errorEnabled=&quot;true&quot;
app:endIconMode=&quot;password_toggle&quot;&gt;
&lt;com.google.android.material.textfield.TextInputEditText
android:id=&quot;@+id/edtpassword&quot;
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;
android:inputType=&quot;textPassword&quot;
android:text=&quot;1234&quot;/&gt;
&lt;/com.google.android.material.textfield.TextInputLayout&gt;
&lt;!-- input Button  --&gt;
&lt;RelativeLayout
android:layout_width=&quot;match_parent&quot;
android:layout_height=&quot;wrap_content&quot;&gt;
&lt;!-- input Button signin --&gt;
&lt;com.google.android.material.button.MaterialButton
android:id=&quot;@+id/signbtn&quot;
android:layout_width=&quot;wrap_content&quot;
android:layout_height=&quot;wrap_content&quot;
android:layout_alignParentEnd=&quot;true&quot;
android:layout_alignParentRight=&quot;true&quot;
android:text=&quot;@string/signin&quot;
app:backgroundTint=&quot;#A8A8A8&quot;/&gt;
&lt;!-- input Button cancel --&gt;
&lt;com.google.android.material.button.MaterialButton
android:id=&quot;@+id/cancel_button&quot;
style=&quot;@style/Widget.MaterialComponents.Button.TextButton&quot;
android:layout_width=&quot;wrap_content&quot;
android:layout_height=&quot;wrap_content&quot;
android:layout_marginEnd=&quot;12dp&quot;
android:layout_marginRight=&quot;12dp&quot;
android:layout_toStartOf=&quot;@+id/signbtn&quot;
android:layout_toLeftOf=&quot;@+id/signbtn&quot;
android:text=&quot;@string/text_cancel&quot; /&gt;
&lt;/RelativeLayout&gt;
&lt;/LinearLayout&gt;
&lt;/ScrollView&gt;

huangapple
  • 本文由 发表于 2020年4月9日 22:05:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/61123041.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定