-2
 <EditText
                    android:layout_width="match_parent"
                    android:layout_height="45sp"
                    android:layout_marginTop="10sp"
                    android:textColor="#000"
                    android:id="@+id/main_email_tv"
                    android:inputType="textCapWords"
                    android:hint="Email"
                    android:textSize="25sp"
                    android:drawableRight="@drawable/lock"

                    />

I am adding lock image in edittext in the right side, but the problem is im not able to adjust image size in edittext.

Actually i was looking for this option and finally got that. android:drawableLeft="@drawable/pic by this option a image can be displayed in extream left of EditText. for other who is looking for same kind of answer must make sure that the size of image should be around 25-35px or else image will not be displayed properly inside editetxt.

2 Answers2

2

set Your Image like this

                   <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="50dp"
                    android:layout_marginTop="30dp"
                   >

                    <EditText
                        android:id="@+id/edt_dob"
                        android:layout_width="0dp"
                        android:layout_height="match_parent"

                        android:layout_gravity="center_vertical"
                        android:layout_weight="1"
                        android:background="@null"
                        android:editable="false"
                        android:focusable="false"
                        android:hint="Date Of Birth"
                        android:paddingLeft="10dp"
                        android:textColor="#ffffff"
                        android:textColorHint="#ffffff" />

                    <ImageView
                        android:id="@+id/img_date"
                        android:layout_width="35dp"
                        android:layout_height="35dp"
                        android:layout_gravity="center_vertical"
                        android:layout_marginRight="10dp"
                        android:src="@drawable/calendar" />


                </LinearLayout>
Tejas Pandya
  • 3,987
  • 1
  • 26
  • 51
  • https://stackoverflow.com/questions/15002963/in-android-how-to-make-login-button-disable-with-respect-to-edittext Sir, see image in this url, see the image left to the username and password , i want same like that just in right direction – Mehtab Alam Oct 07 '17 at 06:38
  • 1
    you have two option . either you have to take your image as your require height and width. or you can also follow above approach . it will do same as you want – Tejas Pandya Oct 07 '17 at 06:41
1

Use this instead of using EditText alone

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="45sp"
    android:layout_marginTop="10sp">

    <EditText  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:gravity="center"
        android:textStyle="bold"
        android:textSize="17sp"
        android:text="How to select and crop image"/>


    <ImageView
        android:id="@+id/iv_photo"
        android:layout_marginTop="10dp"
        android:layout_gravity="center_horizontal"
        android:layout_width="fill_parent"       
        android:layout_height="200dp"/>

</RelativeLayout>
Mehul Vasa
  • 51
  • 9