Padding doesn't work properly in EditText Android Studio - android

Hello I have a question,
In Android Studio's prewiew when I use "padding" and "gravity" those look fine, Galaxy s4, the EditText doesn't show the text in the same position. This show it a little bit above.
thats my xml
<EditText
android:layout_width="100dp"
android:layout_height="wrap_content"
android:inputType="numberDecimal|numberSigned"
android:ems="10"
android:id="#+id/eta"
android:hint="a"
android:paddingBottom="6dp"
android:gravity="center"
android:layout_below="#+id/ecuacion1"
android:layout_marginTop="12dp"
android:layout_centerHorizontal="true"
android:enabled="true"
android:textColor="#ff000000"
android:textColorHint="#ff757575" />
thanks.

Related

EditText height issue in Android 4.4 (Kitkat)

I am developing a sample app with just activation screen. I have one EditText and one Button.
In all android version screen is looking fine except Android 4.4.
I am getting issue with EditText in Kitkat version only. EditText not showing perfect height and also showing some shadow around EditText.
Please see below image for more detail.
In Android 4.4 version
In Other Android version
Below is EditText code in layout xml file.
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_activation_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="Activation Number"
android:maxLines="1"
android:textColor="#575757"
android:textSize="15dp" />
</android.support.design.widget.TextInputLayout>
How can I fit this issue with android 4.4. I also searched on Google too but not getting exact solution of this issue.
I had same issue.
Use android.support.design.widget.TextInputEditText instead of EditText
This solved the problem. Edited in your code
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputEditText
android:id="#+id/edt_activation_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="center"
android:hint="Activation Number"
android:maxLines="1"
android:textColor="#575757"
android:textSize="15dp" />
</android.support.design.widget.TextInputLayout>

TextInputLayout hint is not visible in nexus

In Below Mentioned Code i am not able to see the hint text in nexus phone, in other phone it is working fine, and looks according to code.
<android.support.design.widget.TextInputLayout
android:id="#+id/til"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="#style/TextAppearence.App.TextInputLayout">
<com.hul.humarashop.CustomFontTextView.EditTextGothamBook
android:id="#+id/editName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#00000000"
android:hint="Name"
android:padding="10dp"
android:singleLine="true"
android:textColor="#000000"
android:textColorHint="#000000"
android:textSize="15sp"></com.hul.humarashop.CustomFontTextView.EditTextGothamBook>
</android.support.design.widget.TextInputLayout>
Set the app:hint="Name" on the TextInputLayout, rather than the EditText.
Just to note as well - you might like to know that the TextInputLayout has a getEditText() method! This means you only have to use one id in the xml, tidying up the code a little.

Android Marshmallow breaks old layout

My app was first developed for Android 2.3, but has been updated many times and currently targets V21. So I was surprised when my Nexus 5 received the Marshmallow update and found that a critical feature of my app was broken. I have a screen with a line at the top where I want two buttons at the far right and an EditText box (for search text) filling up the remainder of the screen to the left. This was my first app and I was unclear about various layout techniques, but from Android 2.3 to 5.1 this code has continued to work:
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/upper_detail_section"
android:elevation="#dimen/upper_elevation"
>
<Button android:id="#+id/sort"
style="#style/large_cust_btn"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="#string/sort"
/>
<Button android:id="#+id/clear"
style="#style/large_cust_btn"
android:layout_toLeftOf="#+id/sort"
android:layout_alignParentTop="true"
android:layout_alignWithParentIfMissing="true"
android:text="#string/clear"
/>
<EditText android:id="#+id/lookup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/clear"
android:layout_alignBaseline="#+id/clear"
android:singleLine="true"
android:hint="#string/item_search_hint"
android:scrollHorizontally="true"
android:textSize="16sp"
android:inputType="textFilter"
/>
</RelativeLayout>
Bringing this screen up in Android 6.0, the buttons are there but the EditText field completely disappears! Knowing what I know now it turned out to be a simple fix using a LinearLayout and weighting:
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/upper_detail_section"
android:orientation="horizontal"
android:elevation="#dimen/upper_elevation"
>
<EditText android:id="#+id/lookup"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="#string/item_search_hint"
android:scrollHorizontally="true"
android:textSize="16sp"
android:inputType="textFilter"
/>
<Button android:id="#+id/clear"
style="#style/large_cust_btn"
android:text="#string/clear"
android:onClick="clearClicked"
/>
<Button android:id="#+id/sort"
style="#style/large_cust_btn"
android:text="#string/sort"
android:onClick="sortClicked"
/>
</LinearLayout>
So all is well now and I'm updating the store with a new APK, but I thought I'd warn people that some layout tricks that used to work may now be broken.
If I'm understanding and reproducing your problem correctly, it's quite simple to fix your issues with RelativeLayout as well. Marshmallow only handles a width of match_parent differently. So just set it to something else like with the LinearLayout and alignParentLeft to true:
<EditText android:id="#+id/lookup"
android:layout_alignParentLeft="true"
android:layout_width="0dp"
[...] />
This yielded the same layout for me like in pre Marshmallow.

Justified Text with central alignment in android

Hello everyone, i am working on android application in which i am showing some text using TextView with central alignment on the screen. But the problem is that the text is not properly justified on the screen. This is the xml code which i am using for showing text with central alignment on the screen. Please help me for doing this.
<TextView
android:id="#+id/lastMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center"
android:text="Mana addd asdwd ekff fec greq crrq grooe cieurnf covhrpw cjcneie ejducbc ueiche deidhe idhcecm ekwp ww"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="12sp" />
This library will provide you a way to justify text.
Compatible for Android 2.2 to 5.X
https://github.com/bluejamesbond/TextJustify-Android
If you want to center align text, use android:gravity="center" as follows:
<TextView
android:id="#+id/lastMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center"
android:gravity="center"
android:text="Mana addd asdwd ekff fec greq crrq grooe cieurnf covhrpw cjcneie ejducbc ueiche deidhe idhcecm ekwp ww"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="12sp" />

How to change the color of default underline in textviews for Android App Studio

I am creating a demo app in Android Studio with the following design, but the problem is that when I run the app in my mobile phone, the first underline is green, while the other one looks black. How can I change the color of this automatically generated underlines, so that they both have same color.
I know, I can create a view to add lines, but I like the placement of these lines and was thinking if there is a way to change their color rather than adding new lines through views.
The image I see in my phone:
As you can see the first line becomes green.
Code for first edittext:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:text="#string/today_text"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:inputType="text" />
Code for second edittext:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/editText4"
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/imageView"
android:text="#string/tomorrow_text"
android:inputType="text" />

Categories

Resources