EditText does not display text instantly on some phone - android

In some phones, when I put EditText on the bottom of the screen, texts do not display instantly. Texts display only when soft-keyboard disappears(because of screen refresh). When I put editText on the top of soft-keyboard they are no problem.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="18sp"
android:maxLines="6"
android:minHeight="60dp"
android:paddingLeft="11dp"
android:paddingRight="5dp"
android:textColor="#color/blue_text_style"
android:id="#+id/titrePoste"
android:layout_toLeftOf="#id/btShare"
android:layout_alignParentBottom="true"
android:hint="#string/Objet"
android:background="#android:color/transparent"
android:backgroundTint="#color/color1"
android:textColorHint="#color/gray" />
java code
setContentView(R.layout.activity_post_pic_apercu);
titrePoste = (EditText) findViewById(R.id.titrePoste);

It's happens sometimes maybe you should add hardware Accelerated in manifest
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:roundIcon="#drawable/logo"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true"
android:usesCleartextTraffic="true">

Related

Android Studio - EditText input moves TextView

I have a Text View below an EditText.
When I enter data into the EditText, the TextView moves up, so that it is still visible.
I mean I enter data, the keyboard comes up and the TextView moves also up.
But I don't want that, I want the TextView to stay where it is.
I am using a ConstraintLayout and I can't set the constraints tighter, because the TextView will be filled with data if I hit a button.
<EditText
android:id="#+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:layout_marginTop="50dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:hint="#string/hint1"
android:importantForAutofill="no"/>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constrainedHeight="true">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/emptyString" />
</ScrollView>
what I think is, you have put the text view in the in the scroll view that's why it is behaving in that way.
I found the solution, it was adding this line in the starting activity tag:
android:windowSoftInputMode="adjustPan"
Like this:
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Now when the keyboard appears the TextView is not moving anymore.
It is overlaid by the keyboard, but I like to have it that way rather than having moving views.

Android EditText was not completely visible when keyboard appears

My EditText was not completely visible when the keyboard appears, it was visible till focus but is there any possibility to view complete EditText.
Layout
<ScrollView
android:id="#+id/scrollvew_direct"
android:isScrollContainer="true"
android:layout_height="wrap_content">
<EditText
android:id="#+id/edt_employers_name"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:inputType="text"
android:maxLength="100"
android:hint="#string/dir_deposit_6"
android:textSize="#dimen/edittextsize_sub"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/main_header"
android:textColorHint="#color/hint_color_light"
android:background="#drawable/edittext_style"/>
</ScrollView>
In mainfest
<activity
android:name=".activityname"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
android:theme="#android:style/Theme.Holo.Light.NoActionBar"/>
please guide me for proper solution.
In you activity tag of the manifest , add this property
android:windowSoftInputMode="adjustResize"
Edited :
Edittext height is not fully matched to the background drawable
make edittext as
android:layout_height="match_parent" or
android:layout_height="wrap_content"
and check it for me it is working
In you activity tag of the manifest , add this property
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"

Android EditText under scroll view is scroll to out of screen while typing

In my layout file, I have an EditText, under scrollbar, User can write till 1000 character. I gave Fixed Height to it, when user try to enter text( more then 500 character), It slightly start scrolling to top, and after some time edit text become disappear. I can pulled down to it, but when ever it get focus again, it again scroll to top and disappear. There are lots of View In my screen so Page is quite longer.
Menifest File:
<activity android:name="ActivityName"
android:exported="true"
android:hardwareAccelerated="true"
android:label="#string/title_activity_manage_job"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateHidden" />
My Layout
<android.support.v4.widget.NestedScrollView
android:id="#+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
//Other View are availble on top and bottom of edit textl̥
<EditText
android:id="#+id/edt_profileSummary"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="10dp"
android:background="#drawable/squre_edittext"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:overScrollMode="always"
android:inputType="textMultiLine"
android:gravity="top"
android:maxLength="1000"
android:maxLines="25"
android:padding="10dip"
android:textColor="#android:color/black"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="#dimen/small_text_size" />
</android.support.v4.widget.NestedScrollView>
Please help me, If you understand my problem.

Remove focus from EditText and also keep it editable

I am using EditText but when Activity is started my EditText is already focused. I want to remove focus and also make it editable on click.
Here is the code of my edittext.
<EditText
android:id="#+id/et_HotelLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:drawableLeft="#drawable/ic_edit_location_black_24dp"
android:drawablePadding="8dp"/>
You can create dummy layout as below which you should keep exactly above your EditText and then use nextFocusUp and nextFocusLeft as shown.
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:id="#+id/et"
android:drawablePadding="8dp"
android:nextFocusUp="#id/et"
android:nextFocusLeft="#id/et"
app:met_floatingLabel="normal" />
Add the following two properties in parent Layout of the Edit text
android:focusable="true"
android:focusableInTouchMode="true"
if your edit text is inside linear layout you can do like this
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_HotelLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:drawableLeft="#drawable/ic_edit_location_black_24dp"
android:drawablePadding="8dp"/>
</LinearLayout>
This question has already been responded here
Try this also -
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Otherwise, declare in your manifest file's activity -
<application android:icon="#drawable/icon"
android:label="#string/app_name">
<activity android:name=".Main"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden"
>

Edit text not editable android

I have an Edit Text inside a custom ListView. When I am typing a value in the EditText, it is not showing what I type. If I tap several times on the EditText, it appears the typed text sometimes. How should I overcome this issue?
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/edtReason"
android:background="#drawable/edittextstyle"
android:layout_below="#+id/textView20"
android:layout_toLeftOf="#+id/chkSelect"
android:layout_alignLeft="#+id/textView20"
android:layout_alignStart="#+id/textView20" />
I hope you have added the following property in parent layout of your listview item
android:descendantFocusability="blocksDescendants"
Now add the following in xml of EditText
android:focusableInTouchMode="true"
android:focusable="true"
Add these attributes and try again, Hope this helps
android:hint="Enter Message"
android:inputType="textMultiLine|textPostalAddress"
android:focusable="true"
android:clickable="true"
android:cursorVisible="true"
android:layout_width="50dp"
android:layout_height="wrap_content
android:focusable="true"
android:focusableInTouchMode="true"
android:textColor="#44444"
android:ems="10"
Add this in Manifest:
android:windowSoftInputMode="adjustPan"
Manifest
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<activity
android:name=".ListviewActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">

Categories

Resources