My application has structure like below-
<RelativeLayout>
...
<ScrollView>
<LinearLayout>
....
<EditText ... />
....
</LinearLayout>
</ScrollView>
...
</RelativeLayout>
When I am trying to input values in EditText, it loses focus and scrolls up to top.
It is focused when I first click it, but loses when I click any values (a-z) of softkeyboard.
Important issue is Application works fine on other devices and has this error only on certain devices (e.g. galaxy S4)
I already made 'adjustpan' and EditText's focusable true.
And there is no focus handling source in .java file.
Anyone has solution to this problem?
or Galaxy S4 has any issue on this problem?
I found the reason.
This issue only works on the condition below
Galaxy S4
using EditText with 'number' inputType
using gravity not left
(only horizontal gravity makes issue. any vertical gravity works as normal)
So I did like below
make empty space (marginBottom) so that keyboard may not block edittext
For some Edittext, set gravity to left and calculate device pixel and give edittext marginLeft
so that edittext works as if it's gravity is right
If anyone has better solution, please tell me how..
Related
I'm developing an Android application in which I have an EditText control.
I've set the gravity to right, in order to type in Persian.
But when I try to select a text (which is in Persian), the select pointers won't appear.
It works almost fine when the gravity is not set. Also it works fine in other devices like Samsung. But it doesn't work on HTC devices (HTC One xl in my case).
This is my EditText xml
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/txtShare"
android:layout_weight="1"
android:enabled="true"
android:inputType="text|textMultiLine"
android:hint="#string/typeHere"
android:gravity="right"/>
Does anyone know how to fix this?
Edit 1
Also the cursor is always at the beginning of the lines, no matter where I tap in the text.
Edit 2
I'm almost sure that if I can solve the problem in Edit 1, the first problem will be solved along with it. Cause wherever I click in text, the cursor would remain in the beginning of the line
Try adding following attribute to your EditText
android:ellipsize="end"
If you are using right-to-left text you should use the textDirection property for correct support. Gravity only aligns text, so text you enter would still be left-to-right.
The cursor selection is handled in the onTouchEvent method.
I don't have any HTC device, so just an idea.
Maybe you can try to find the problem from the onTouchEvent method.
This is the picture:
When I click on the "Confirm password" EditText, for the first time, it works the way it should - layout pops up so I can enter text in selected EditText, but when I dismiss keyboard(that EditText still focused) and click on that same EditText again, it stays under keyboard.
Main layout is RelativeLayout, input fields are in ScrollView and buttons are in LinearLayout aligned to parent bottom.
In manifest I have android:windowSoftInputMode="adjustPan".
Is this some Android issue or I've been doing something wrong?
It's actually a bug in EditText. try removing gravity of EditText, which could be either center_horizontal or center
Got the answer from another question. check this.
For me removing android:minWidth does the trick
I just came with a workaround for this problem as well, I got my edit text to start the text in the middle of the screen with a not so great solution, but it works for me. The code is this one:
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:paddingStart="130sp"
android:paddingEnd="50sp"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:gravity="bottom"/>
I'm not looking for code, either I won't post any, just an explanation, because I'm kind of lost.
There is this main issue about the resizing when softkeyboard appear.
In my case
I have a listView feeded with 2 editText and many textView with database content using a custom cursorAdapter.
1) AdjustPan
It's pretty simple. When I use the adjustPan property, everything works quite good, except the fact that when I press an editText in my listView and if the listview is bigger than the screensize, I can't scroll. This is actually the normal behaviour and I can understand it.
2) AdjustResize
Here I can scroll as much as I wish.
This property is the one I want to use. But I'm facing 2 issues :
When I press on one of the two editText, I just can't write in. Impossible, even thought it has the focus. I'm forcing the softkeyboard to appear, I try to type some letters in (remember that this editText is focused) but nothing happens.
Again, when I press one of the two editText, it just reorganize (apparently randomly) listview's items. Even thought it's working perfectly with adjustPan, with adjustResize, it's messing with items of the listView.
Any information about one of the 2 issues would be helpful. You can even ask for code, but one more time, I'm just looking for a general explanation that could help. Thanks.
Here this mention issue is same facing me in my app and here some change in my code is this working fine in my app. please try this...
<activity android:name="com.MainActivity"
android:configChanges="orientation|screenSize"/>
<ListView
android:id="#+id/fields_list_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="afterDescendants"
android:focusableInTouchMode="true"
android:focusable="true"
/>
<EditText
android:id="#+id/input_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:cursorVisible="true"
android:gravity="top"
android:inputType="none"
android:textColor="#color/black"/>
developing an android app here using API 7. I have an EditText that we use to filter down the list beneath it, so we set the inputType to textFilter so Android wouldn't suggest words or auto-complete.
However, when the user types a character they see the popup box in which they're doing the search shrink. It is clearly getting smaller to make room for the suggestion bar, even though the suggestion bar doesn't actually show.
Using textNoSuggestions instead appears to have the same result. Here is the snippet for the input box:
<EditText
android:id="#+id/search_edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:inputType="textFilter"
android:background="#null"/>
Has anyone experienced and overcome this behavior? It doesn't repro on SenseUI, but probably because SenseUI floats the suggestion bar instead of claiming screen real estate for it.
Try textNoSuggestions. I'm not sure what textFilter does, I was hoping to use it to limit input to 0-9 and A-F for a hex keyboard, but found this instead.
The only thing that works consistently in my experience is textVisiblePassword. This both prevents autocorrection and doesn't change the size of the field. Very annoying.
I have a simple user interface: an EditText should be located below a SurfaceView.
I use a RelativeLayout to arrange these two views.
Now, when I tap on the EditText to open the virtual keyboard the SurfaceView slides up but the EditText is hidden and does not show the typed string.
To reproduce, use the following layout XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RelativeLayout01"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<SurfaceView
android:id="#+id/SurfaceView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</SurfaceView>
<EditText
android:id="#+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:selectAllOnFocus="true"
android:textStyle="normal"
android:singleLine="true">
</EditText>
</RelativeLayout>
The main Activity class only needs to show the layout. When I start the program and tap the EditText, the virtual keyboard appears but the EditText field is gone.
Maybe the RelativeLayout is causing the problems, but I don't know how to reproduce the same layout with another Layout class.
Any suggestions are welcome, I really appreciate your help.
Thanks.
Edit:
Here are two screenshots, one showing the EditText at the bottom without virtual keyboard, one with virtual keyboard but with no EditText. It is interesting to note that the SurfaceView and the EditText actually shift upward, the EditText just disappears. BTW this also happens to a button if it is next to the EditText.
EditText below a SurfaceView (left); EditText is gone (right)
As a commenter in the thread about this bug suggested, it is very easy to fix this problem by setting the background color of the SurfaceView or GLSurfaceView to transparent with mSurfaceView.setBackgroundColor(Color.TRANSPARENT); as well.
This problem occurred for me when pressing an EditText on Honeycomb (v13) on a Samsung Galaxy Tab 10.1. The issue was that after the GLSurfaceView was resized, in its place was still a black rectangle which was covering the EditText. This solution works by making that erroneous rectangle transparent, so the EditText can be seen.
Add the follow code for your activity in your AndroidManifest.xml
android:windowSoftInputMode="adjustPan"
Yes, it's right!
Add the follow code for your activity in your AndroidManifest.xml android:windowSoftInputMode="adjustPan"
And in your edit text, just add:
android:imeOptions="flagNoFullscreen"
i found that it has different result on different devices,then i use ScrollView as the root view and put the layout into ScrollView, when use fullScreen mode it works fine. and be sure to set android:fillViewport="true" if you still have some problem let me know liananse#163.com