android: How to set margin/padding between EditText custom background and InputTextLayout Label? -


well want set margin/padding between edittext , inputtextlayout label on pressed state.

here's image of - desired design

main xml code - `

<linearlayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_margintop="56dp"     android:gravity="center_horizontal"     android:orientation="vertical"     android:paddingleft="24dp"     android:paddingright="24dp">      <imageview         android:id="@+id/imageview"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_marginbottom="24dp"         android:src="@drawable/headphones_3" />      <android.support.design.widget.textinputlayout         android:id="@+id/textlabel"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_marginbottom="8dp"         android:layout_margintop="8dp"         android:visibility="gone"         app:theme="@style/textlabel">          <edittext             android:id="@+id/input_email"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:hint="email"             android:inputtype="textemailaddress" />     </android.support.design.widget.textinputlayout>      <android.support.design.widget.textinputlayout         android:id="@+id/password_label"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:visibility="gone"         app:theme="@style/textlabel">          <edittext             android:id="@+id/input_password"             android:layout_width="match_parent"             android:layout_height="40dp"             android:background="@drawable/edit_text_style"             android:drawablepadding="@dimen/floating_hint_margin"             android:hint="password"             android:inputtype="textpassword"             android:paddingleft="@dimen/floating_hint_margin" />      </android.support.design.widget.textinputlayout> </linearlayout> 

`

though right applied custom theme 'password" textinputlayout.!

here code of edit_text_style

<selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- focused state --> <item android:state_focused="true">     <shape android:shape="rectangle">         <solid android:color="#80ffffff" />         <stroke android:width=".5dp" android:color="@color/colorprimary" />         <corners android:radius="6dp" />     </shape> </item> <!-- normal state --> <item>     <shape>         <solid android:color="@android:color/transparent" />         <stroke android:width="2dp" android:color="@color/colorprimary" />         <corners android:radius="22dp" />     </shape> </item> 

the result got - resulted image

as can see label goes cursor , there's no padding between label , edittext background.

and how set label edittext background starts ( it's on top of cursor right )?

( sorry bad english )

update : let me explain - see images again.! want set padding between textinputlayout label ( password here when focus ). guys said creating padding between custom drawable ( edit_text_style here ) cursor , label, want padding between drawable added , label ( password text appear when it's on focused state ) & want set label position it's goes upward cursor start.!

you can apply custom style edittext (the ones need have padding onpressedstate) :

<edittext         android:id="@+id/input_email"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:hint="email"         android:inputtype="textemailaddress" /> 

and style :

    <?xml version="1.0" encoding="utf-8"?>     <selector xmlns:android="http://schemas.android.com/apk/res/android">        <item android:state_focused="true"              android:state_pressed="true"              android:drawable="@drawable/next_white">              <inset android:insetleft=""your_padding_in_dp dp"/> 

source : android:drawableleft margin and/or padding

for margin, isn't possible drawable, can still define animation trick :

in res/anim, create margin_animation.xml :

    <?xml version="1.0" encoding="utf-8"?>      <set xmlns:android="http://schemas.android.com/apk/res/android"              android:interpolator="@android:anim/accelerate_interpolator">                <translate android:fromydelta="0" android:toydelta="100%" />     </set> 

source : in android, possible set margin drawable?


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -