1

I have an editext with two images one in left side and one in right side, these three views(edittext and both images should appear in a white background) and when user click on editext, its text should move to top-left corner, means just above the left image. What i tried is this:

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

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:paddingTop="@dimen/dim_7">

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/dim_45"
                        android:layout_alignParentBottom="true"
                        android:layout_centerVertical="true"
                        android:background="@drawable/rounded_solid_white" />

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

                        <ImageView
                            android:id="@+id/imgName"
                            android:layout_width="@dimen/dim_21"
                            android:layout_height="@dimen/dim_21"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="@dimen/dim_10"
                            android:src="@drawable/name" />

                        <com.investorapp.others.custom_view.MyTextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content">

                            <com.investorapp.others.custom_view.MyEditTextRegular
                                android:id="@+id/etLogInEmailId"
                                style="@style/MyEditTextStyle"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginRight="@dimen/dim_10"
                                android:gravity="center_vertical"
                                android:hint="Enter Email Address"
                                android:inputType="textEmailAddress"
                                android:paddingBottom="@dimen/dim_10"
                                android:layout_marginBottom="@dimen/dim_15"
                                android:paddingLeft="@dimen/dim_40"
                                android:paddingRight="@dimen/dim_10"
                                android:paddingTop="@dimen/dim_20" />
                        </com.investorapp.others.custom_view.MyTextInputLayout>

                        <ImageView
                            android:id="@+id/imgValidEmail"
                            android:layout_width="@dimen/dim_21"
                            android:layout_height="@dimen/dim_21"
                            android:layout_alignParentRight="true"
                            android:layout_centerVertical="true"
                            android:layout_marginRight="@dimen/dim_10" />
                    </RelativeLayout>
                </RelativeLayout>


            </RelativeLayout>

my output of above code is like this image enter image description here

But that's not what i want. My expected output is this: enter image description here

Any help would be much appreciated. If there is any library available that would also helpful.

Suraj Vaishnav
  • 7,777
  • 4
  • 43
  • 46
  • you will have to implement your own styles or give some margins or padding to the hint. – Umair Feb 08 '18 at 10:42
  • I tried everything with padding and margin by edittext's text move to 90 degree – Suraj Vaishnav Feb 08 '18 at 10:45
  • did you tried using styles ? – Umair Feb 08 '18 at 10:49
  • 1
    No, i did'nt find any useful styles to work in that,if you have some please put in answer – Suraj Vaishnav Feb 08 '18 at 10:51
  • It looks like you could simplify that setup quite a bit by setting the `rounded_solid_white` background directly on the `EditText`, and using the images as its compound drawables - i.e., `drawableLeft`, `drawableRight`, etc. - instead of the separate `ImageView`s. Then [my answer here](https://stackoverflow.com/a/39568320) shows how you can align the floating hint all the way to the left, over that drawable. If you can't change your setup, for whatever reason, that answer should at least give you some ideas as to how to move that hint a bit. – Mike M. Feb 08 '18 at 10:52
  • 1
    take a look at this answer. it will give you the idea how to do it. https://stackoverflow.com/questions/32609710/textinputlayout-how-to-give-padding-or-margin-to-hint And also mike's comment will surely help you – Umair Feb 08 '18 at 10:58
  • 1
    Thanks Mike you solution work for me, Thanks Umair for replying – Suraj Vaishnav Feb 08 '18 at 13:02

0 Answers0