user8694522
user8694522

Reputation:

How to make edittext to password type?

I tried to solve this problem myself.

But I couldn't be done it.


Strangely, I can't see anything on typing password.

enter image description here

I just would like this.

enter image description here

My code is below.

      <EditText
                android:id="@+id/user_password"
                android:layout_width="match_parent"
                android:layout_height="54dp"
                android:background="@drawable/join_edittext"
                android:hint="password"
                android:paddingStart="15dp"
                android:paddingTop="2dp"
                android:inputType="textPassword"
                android:textSize="18sp" />

join_eddittext is below.

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
    <solid android:color="#EDEDED" />
    <stroke android:width="1dp" android:color="#DFDFDF" />
</shape>

What's the matter with this?


Below is all of main xml code.

(*) 1. If you take CustomHeader, please add comment. 2. drawable of ImageView are .svg files.

<?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:orientation="vertical"
    tools:context="com.hanlab.hero.JoinActivity"
    android:focusable="true"
    android:focusableInTouchMode="true">

    <com.hanlab.hero.components.CustomHeader
        android:id="@+id/ui_header_component"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:img="@drawable/ic_join_title"
        app:text="회원가입"></com.hanlab.hero.components.CustomHeader>

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:orientation="vertical"
            android:paddingLeft="33dp"
            android:paddingRight="33dp"
            android:paddingBottom="100dp">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                android:orientation="horizontal">

                <android.support.v7.widget.AppCompatImageView
                    android:layout_width="54dp"
                    android:layout_height="54dp"
                    android:layout_gravity="center"
                    android:adjustViewBounds="true"
                    android:background="@color/mainColor"
                    android:paddingBottom="4dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="12dp"
                    android:paddingTop="4dp"
                    app:srcCompat="@drawable/ic_join_usr" />

                <EditText
                    android:id="@+id/user_name"
                    android:layout_width="match_parent"
                    android:layout_height="54dp"
                    android:background="@drawable/join_edittext"
                    android:hint="성함"
                    android:paddingStart="15dp"
                    android:paddingTop="2dp"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                android:orientation="horizontal">

                <android.support.v7.widget.AppCompatImageView
                    android:layout_width="54dp"
                    android:layout_height="54dp"
                    android:layout_gravity="center"
                    android:adjustViewBounds="true"
                    android:background="@color/mainColor"
                    android:paddingBottom="12dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="12dp"
                    android:paddingTop="12dp"
                    app:srcCompat="@drawable/ic_join_age" />

                <EditText
                    android:id="@+id/user_age"
                    android:layout_width="match_parent"
                    android:layout_height="54dp"
                    android:background="@drawable/join_edittext"
                    android:hint="연령"
                    android:inputType="number"
                    android:paddingStart="15dp"
                    android:paddingTop="2dp"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                android:orientation="horizontal">

                <android.support.v7.widget.AppCompatImageView
                    android:layout_width="54dp"
                    android:layout_height="54dp"
                    android:layout_gravity="center"
                    android:adjustViewBounds="true"
                    android:background="@color/mainColor"
                    android:paddingBottom="12dp"
                    android:paddingLeft="12dp"
                    android:paddingRight="12dp"
                    android:paddingTop="12dp"
                    app:srcCompat="@drawable/ic_join_gender" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="54dp"
                    android:background="@drawable/join_edittext"
                    android:gravity="center_vertical"
                    android:orientation="horizontal"
                    android:paddingLeft="12dp">

                    <RadioGroup
                        android:layout_width="fill_parent"
                        android:layout_height="50dp"
                        android:id="@+id/radio_sex_group"
                        android:checkedButton="@+id/radio_man"
                        android:gravity="center_vertical"
                        android:orientation="horizontal">
                        <RadioButton
                            android:id="@+id/radio_man"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:buttonTint="@color/mainColor"
                            android:paddingLeft="5dp"
                            android:text="남자"
                            android:textColor="#8d8d8d"
                            android:textSize="18sp" />

                        <RadioButton
                            android:id="@+id/radio_woman"
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:layout_marginLeft="10dp"
                            android:buttonTint="@color/mainColor"
                            android:paddingLeft="5dp"
                            android:text="여자"
                            android:textColor="#8d8d8d"
                            android:textSize="18sp" />
                    </RadioGroup>
                </LinearLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                android:orientation="horizontal">

                <android.support.v7.widget.AppCompatImageView
                    android:layout_width="54dp"
                    android:layout_height="54dp"
                    android:layout_gravity="center"
                    android:adjustViewBounds="true"
                    android:background="@color/mainColor"
                    android:paddingBottom="15dp"
                    android:paddingLeft="3dp"
                    android:paddingRight="3dp"
                    android:paddingTop="15dp"
                    app:srcCompat="@drawable/ic_join_email" />

                <EditText
                    android:id="@+id/user_email"
                    android:layout_width="match_parent"
                    android:layout_height="54dp"
                    android:background="@drawable/join_edittext"
                    android:hint="이메일"
                    android:paddingStart="15dp"
                    android:paddingTop="2dp"
                    android:textSize="18sp" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="14dp"
                android:orientation="horizontal">

                <android.support.v7.widget.AppCompatImageView
                    android:layout_width="54dp"
                    android:layout_height="54dp"
                    android:layout_gravity="center"
                    android:adjustViewBounds="true"
                    android:background="@color/mainColor"
                    android:paddingBottom="9dp"
                    android:paddingLeft="13dp"
                    android:paddingRight="13dp"
                    android:paddingTop="9dp"
                    app:srcCompat="@drawable/ic_join_pw" />

                <EditText
                    android:id="@+id/user_password"
                    android:layout_width="match_parent"
                    android:layout_height="54dp"
                    android:background="@drawable/join_edittext"
                    android:hint="패스워드"
                    android:paddingStart="15dp"
                    android:paddingTop="2dp"
                    android:inputType="textPassword"
                    android:textColor="#484343"
                    android:textSize="18sp" />
            </LinearLayout>

            <Button
                android:id="@+id/join_btn"
                android:layout_width="match_parent"
                android:layout_height="54dp"
                android:layout_marginTop="15dp"
                android:background="@color/mainColor"
                android:text="가입하기"
                android:textColor="#fff"
                android:textSize="18sp" />

            <TextView
                android:id="@+id/login_btn"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_gravity="right"
                android:gravity="right"
                android:textSize="13dp"
                android:textColor="#888"
                android:padding="5dp"
                android:text="이미 회원이신가요? 로그인 하기"/>
        </LinearLayout>

    </ScrollView>

</LinearLayout> 

Upvotes: 0

Views: 1038

Answers (4)

Abhishek
Abhishek

Reputation: 3398

You have to set text color (Default text color and background colour are same so you are facing this issue)

  android:textColor="#000000";
  //OR
  android:textColor="#FFFFFF";
  //OR
  android:textColor="@android:color/black";
  //AND ALSO SET
  android:textColorHint="@android:color/black";

Upvotes: 1

Nandkishor Jatoliya
Nandkishor Jatoliya

Reputation: 22

It is just because of text color and background color is same .Just change it to using textcolor ptoperty.you will see typed password.

Upvotes: 0

Payal Sorathiya
Payal Sorathiya

Reputation: 754

 <EditText
   android:id="@+id/user_password"
   android:layout_width="match_parent"
   android:layout_height="54dp"
   android:background="@drawable/join_edittext"
   android:hint="password"
   android:paddingStart="15dp"
   android:paddingTop="2dp"
   android:textColor="@android:color/black"
   android:inputType="textPassword"
   android:textSize="18sp" />

Set your android:textColor , hear your background color and text color are same so not display password input.

Upvotes: 1

Abhishek Dubey
Abhishek Dubey

Reputation: 945

Remove the background and then try problem would be resolved.

Upvotes: 0

Related Questions