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>
Related
I was following along some Android tutorial on Youtube when I encountered the following problem:
(left the designer, right the emulator)
I tried searching on google, but can't seem to find the right link.
Does anyone have any idea what is going on? I tried deleting and placing new elements, but the same problem keeps occurring.
[Edit]
XML code which I didn't change. This was created with a new project.
All elements in the picture were dragged and dropped. No code was changed.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:visibility="visible"
tools:context="com.example.todor.myapplication.MainActivity">
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_editor_absoluteX="159dp"
tools:layout_editor_absoluteY="235dp"
tools:text="#string/loginbutton" />
<TextView
android:id="#+id/textView2"
android:layout_width="132dp"
android:layout_height="31dp"
android:layout_marginBottom="42dp"
android:fontFamily="monospace"
android:textAlignment="center"
android:textColor="#color/colorAccent"
android:textColorHint="#android:color/holo_blue_bright"
android:textStyle="bold"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="#+id/editText"
tools:text="#string/logintext"
tools:layout_editor_absoluteX="126dp" />
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="33dp"
android:width="300dp"
android:ems="10"
android:hint="#string/emailhint"
android:inputType="textEmailAddress"
app:layout_constraintBottom_toTopOf="#+id/editText2"
tools:layout_editor_absoluteX="42dp" />
<EditText
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="40dp"
android:width="300dp"
android:ems="10"
android:hint="#string/passowrdhint"
android:inputType="textPassword"
app:layout_constraintBottom_toTopOf="#+id/button"
tools:layout_editor_absoluteX="42dp" />
</android.support.constraint.ConstraintLay
out>
Here are some tips for you !
Read about Tools Attributes Reference
Android Studio supports a variety of XML attributes in the tools namespace that enable design-time features (such as which layout to show in a fragment) or compile-time behaviors (such as which shrinking mode to apply to your XML resources). When you build your app, the build tools remove these attributes so there is no effect on your APK size or runtime behavior.
You need to understand the difference of below attributes!
tools:text="loginbutton"
android:text="loginbutton"
Your views are not constrained they have only design time position!
Go to the design, drag the corners until the circle turns green and then give the constraint.Here is an extra guidance from linkOne LinkTwo related with ConstraintLayout
If you mess it up big-time you can replace android.support.constraint.ConstraintLayout with LinearLayout but that's not the solution it's another way instead!
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.
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.
I developing android application and this problem I've get stuck on since yesterday and I don't know what is the problem.
the edit text doesn't take numeric input. my XML code
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="#dimen/dp5">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp15"
android:orientation="horizontal"
android:weightSum="2">
<EditText
android:id="#+id/home_et_code"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.3"
android:hint="#string/code_number"
android:inputType="number"
android:maxLength="18"
android:maxLines="1" />
<Button
android:id="#+id/home_btn_charge"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:text="#string/charge"
android:textAppearance="?android:attr/textAppearanceButton"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout></LinearLayout>
if I remove android:inputType="number" then it starts working and takes input, but I need the edit text to accept only numeric input.
I didn't handle anything in java yet. so no need to add the java code.
NOTE: it works fine on android > 14, but on Gingerbread devices the problem occurs
what is the problem??
android:digits="1234567890"
try to put this line on your edittext
now it works fine, because I updated android sdk platform I noticed a lot of problems like the edit text input also back button press is not detected in code. but all what I have to do is to close android studio and reopen it then I compile my application. finally it works again!!
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.