Android multiline EditText - android

I've one EditText with multi-lines.
The problem is that, while I am adding more and more lines, just pressing ENTER or typing, the EditText keeps scrolling down which is OK, but after approx. 10 lines whole activity is scrolling.
And when I click again on EditText, the opened keyboard covers whole EditText.
But, when I click only on 3rd line, keyboard isn't covering EditText and View is moved like it should have.
Any advice please?

Okay,Using EditText in ScrollView Like this way
<ScrollView
android:layout_height="100dp"
android:layout_width="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#54D66A"
android:textSize="17sp" />
</ScrollView>
For programmatic approach please check
http://developer.android.com/reference/android/text/method/ScrollingMovementMethod.html

You can give android:maxHeight="60dp" to your EditText to stop scrolling of the whole Activity and it will solve other problem also.
I hope it helps.

Related

Two fragments stacked ontop of each other using transactional ADD - how to prevent edit text gaining focus on bottom fragment?

Try stacking two fragments with editTexts on top of each other using an Add Transaction. after that when you press the keyboard imeOption key next button the bottom fragment's edit text can gain focus. this is a security concern. user can type things into the bottom fragments edit text (blindly). I tried the following code:
android:filterTouchesWhenObscured="true"
but it has not helped at least on api 27.
my edit text itself looks like this, nothing special:
<EditText
android:id="#+id/et"
android:layout_width="195dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:imeOptions="actionNone"
android:layout_marginBottom="10dp"
android:hint="#string/enter_name"
android:filterTouchesWhenObscured="true"
android:inputType="textNoSuggestions"
android:textColorHint="#959595"
android:textSize="11sp" />
the issue is very similar to android tap jacking
i tried even doing this:
android:nextFocusDown="#+id/et_two" thinking it would bypass and go directly to the edittext i want. but instead the bottom edit text still gains focus.
the issue solution was surprising. recyclerview was stealing focus. see this SO incident:
adding android:descendantFocusability="blocksDescendants" to the recyclerview stopped the issue.

Keyboard over EditText on second click

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"/>

How to keep cursor from going to editText field on activity start android

I am having a problem with text edits. I suppressed the keyboard from poping up on activity start, but how do I keep the cursor from being on the first edit text? I want the cursor to appear only when the editText field is clicked and when the activity starts.
<EditText
android:id="#+id/stuff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/stufflabel"
android:layout_toRightOf="#+id/stuffpic"
android:hint="#string/name_str"
android:maxLength="20"
/>
Kindly search the forum for similar posts.
one post i found is -
Android: Force EditText to remove focus?
I hope you are looking for something similar !
enjoy :)
You can add a dummy EditText on inside layout of the XML file, so that the focus will get on that EditText and not on other EditText.
<EditText
android:layout_width="0dp"
android:layout_height="0dp" />

How to display multiple lines of text with scrolling in android?

I want to display multiple lines of text in my application in particular range such that user can scroll to view other lines. I have tried EditText, but it generates keyboard on top of it and doesn't scroll properly. Then I tried TextView, it also does not scroll the text properly as I wanted.
Is there any other option available? If No, then how to scroll the text vertically in TextView or EditText? I want to scroll the text on drag as in WebView. NOT auto scroll.
You can limit the Height of TextView to match the number of lines you user wants to see, then simply put your TextView in a ScrollView
I had done a simple example to demonstrate this...
<ScrollView android:layout_height="30dp"
android:layout_width="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:textSize="16sp"
android:id="#+id/tv1"
/>
</ScrollView>
Check below code
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:textSize="17dip"
android:inputType="textMultiLine"
android:scrollbars="vertical"
/>
It is possible to create multiline text view with scroll view. I used the following code in your application:
Txt_VistaRecetasola = (TextView) findViewById(R.id.txt_vistarectsola);
Txt_VistaRecetasola.setMovementMethod(ScrollingMovementMethod.getInstance());
Txt_VistaRecetasola.setScrollBarStyle(0x03000000);
Txt_VistaRecetasola.setVerticalScrollBarEnabled(true);
Txt_VistaRecetasola.setTextColor(0xFF000000);
Try using Edittext with making it un editable, so in this case it wont allow keyboard to popup.
android:windowSoftInputMode="stateAlwaysHidden" in your Manifest file in the activity where you have your EditText.

Android's EditText is hidden when the virtual keyboard is shown and a SurfaceView is involved

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

Categories

Resources