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"
Related
I have 2 text fields in the start page. But the first text field gets auto focus after launch. I don't want this. I have seen couple of answers regarding this, but none of that work for me.
My Code
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:drawablePadding="12dp"
android:padding="10dp"
android:ems="10"
android:hint="Username"
android:inputType="textEmailAddress"
android:textColorHint="#android:color/white"
android:layout_marginTop="70dp"/>
I have added two more line here
android:focusable="true"
android:focusableInTouchMode="true"
But still it gets auto focus
Try this use android:windowSoftInputMode="stateAlwaysHidden" in manifest file of your Activity
<activity
android:name=".Youractivity"
android:windowSoftInputMode="stateAlwaysHidden" />
EDIT
I have added two more line here
android:focusable="true"
android:focusableInTouchMode="true"
the above line is used for requesting focus rather than not focusing
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"
>
I have an editText on the main page. I want the keyboard to open automatically when the app starts and to be focused on that editText. I tried many "solutions" I found on the Internet but nothing helped me.
The keyboard still doesn't appear automatically.
By the way, my editText has the following properties:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:gravity="left"
android:focusable="true"
android:enabled="true"
android:focusableInTouchMode="true" />
So how do I make the keyboard appear automatically?
You have to do two things (I have just tested this and it works just fine):
1: request focus for the field.
From the activity java file you can do
mTextView = (EditText) findViewById(R.id.textView);
mTextView.requestFocus();
From the XML file you can rewrite your element as follows:
<EditText android:id="#+id/textView">
<requestFocus/>
</EditText>
2: Force the keyboard when showing the activity: in the onCreate method just write this line:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
Add android:windowSoftInputMode="stateAlwaysVisible" to your activity tag in the AndroidManifest.xml file
<activity
android:name=".TestActivity"
android:windowSoftInputMode="stateAlwaysVisible" />
Also use requestFocus tag in EditText.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:gravity="left"
android:focusable="true"
android:enabled="true"
android:focusableInTouchMode="true">
<requestFocus />
</EditText>
Call myeditText.requestFocus() after you initialize your layout on your activity's onCreate() method.
I have a simple layout for my activity:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="#+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonCancel"
android:layout_alignParentTop="true" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="cancel" />
</RelativeLayout>
and when I touch on EditText soft keyboard appears but my button hides beyond the keyboard !
but I wanna the Button move up (above of) the keyboard.
I added this line of code to AndroidManifest but nothing changed.
<activity
android:name=".Activity"
android:windowSoftInputMode="adjustPan|adjustResize">
</activity>
According to the official documentation adjustPan and adjustResize have an opposite behaviour and therefore I don't think they should be used together. Try just android:windowSoftInputMode="adjustResize" , worked for me.
I want to display the number keyboard.
Here is my code to do that. (This is an item of my list).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/checked_list_item_text"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/checked_list_item_quatity"
android:layout_centerVertical="true"
android:textSize="30sp" />
<EditText
android:id="#+id/checked_list_item_quatity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="7dp"
android:gravity="center_vertical"
android:hint="Quantité"
android:focusableInTouchMode="true"
android:inputType="number"
android:maxLength="6"
android:textSize="30sp" />
</RelativeLayout>
When I click on edittext, the keyboard displays the numbers but switches quickly to text and I have to click a second time to get the number keyboard.
This issue occurs only the first time when I open the activity.
Try changing the input mode in your AndroidManifest.xml
I had the same issue when trying to get focus to an edittext field thats inside a listview. Adding android:windowSoftInputMode="adjustPan" in the activity holding the listview solved the problem for me.
<activity android:name=".MyEditTextInListView"
android:label="#string/app_name"
android:windowSoftInputMode="adjustPan">
What you have should work , but it could be something on the code side. Maybe you can force it programmatically:
EditText checkedInput = (EditText) findViewById(R.id.checked_list_item_quatity);
checkedInput.setInputType(InputType.TYPE_CLASS_NUMBER);