so I've got the following layout with the following TextInputEditText :
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/note"
android:layout_marginTop="#dimen/layout_margin_default"
app:startIconDrawable="#drawable/baseline_notes_24">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
/>
</com.google.android.material.textfield.TextInputLayout>
Right now, when I select to write inside the TextInputEditText the keyboard automatically displays below the TextInputEditText:
Now, what I want to is that rather displaying the keyboard below the TextInputEditText, I want the display to keyboard below the current "selected" line, which should look like this:
Example video how it should look like:
https://jumpshare.com/v/TAO6jo1jdnRZDhYyzrkY
How can this be solved in the right way?
I've tried using android:windowsoftinputmode, but I couldn't find the appropriate attribute.
I'm assuming there is not much leeway when it comes to the displaying the keyboard?
Related
I have a layout where I want to show a bunvh of edit texts and a date picker. Since I want to have the same design for all fields, I figured out that I need to user an edit text for date picker too but make it non editable but clickable. Below is the xml code of my edit text that will be used to show the date picker :
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/notification_layout"
style="#style/Theme.Connect.InputFieldLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:startIconDrawable="#drawable/ic_stk_notification_24dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/notification_edit_text"
style="#style/Theme.Connect.InputField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Notification"
android:maxLines="1"
android:lines="1"
android:cursorVisible="false"/>
</com.google.android.material.textfield.TextInputLayout>
I tried many solutions I found on the internet, I did managed to make edit text non editable but without the ripple click effect. Is there a way to make the edit text non edditable but still keep the ripple click effect? Is this the best practice to show a date picker consisting the design of the form layout?
Try this and change the `android:focusable` attribute to `false`
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/notification_layout"
style="#style/Theme.Connect.InputFieldLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:startIconDrawable="#drawable/ic_stk_notification_24dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/notification_edit_text"
style="#style/Theme.Connect.InputField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Notification"
android:maxLines="1"
android:focusable="false"
android:lines="1"
android:cursorVisible="false"/>
</com.google.android.material.textfield.TextInputLayout>
You can simply use a TextView instead of an EditText and you can set an onClickListener() to it. You can also style it the way you want.
notification_textview.setOnClickListener {
// Whatever you want to do after a click
}
You can get a ripple effect on touch by adding these 2 attributes to your textview
<......Textview
android:background=?android:attr/selectableItemBackground
android:clickable="true" />
You can also add styles to a textview that you wanted to use for the editText.
I have made an EditText in order to search for something.
The EditText looks like this:
The xml of this is:
<EditText
android:id="#+id/Et_Search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="24dp"
android:layout_marginTop="24dp"
android:layout_marginStart="24dp"
android:layout_marginBottom="8dp"
android:background="#drawable/et_rounded"
android:hint="#string/Activity_Search"
android:imeOptions="actionSearch"
android:inputType="text"
android:paddingStart="56dp"
android:paddingEnd="64dp"
android:textColorHint="#color/colorGray"
android:textSize="16sp"
app:layout_constraintTop_toTopOf="parent" />
Since im using android:imeOptions="actionSearch", the keyboard that opens when I type looks like this:
I was wondering if there is an option to change the color of the circle from green to some other color?
It seems like this green is some Primary color of the app however I don't have this color anywhere.
Thank you
As you may have already explored that you can modify the action button from the keyboard, by setting imeOptions. But you cannot override Icons, colors or backgrounds or the keys of the System provided Soft Keyboard.
To do so you may have to implement your custom keyboard. like so you can modify everything in keys of that Custom Keyboard View.
I create EditText. How to get Keyboard object and set myself setting. For example set first letter in upper case when I focused on EditText.
You can simply add 'android:inputType="textCapSentences"' to you EditText element in you XML layout. as example:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:padding="8dp"
android:textSize="18sp"
android:inputType="textCapSentences"/>
It could not be applied automatically on a Emulator like GenyMotion, but if you test it on a device it would.
Good luck
I have this EditText
<EditText
android:layout_width="match_parent"
android:layout_height="72dp"
android:hint="#string/write_message"
android:textColorHint="#color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:inputType="textImeMultiLine"
android:id="#+id/message_input"
android:layout_gravity="center_horizontal"
android:backgroundTint="#color/primary_color"/>
When the box is filled up with user inputted text, it scrolls to the right to make room for more text, I do not like this behavior, and would prefer it if the EditText box expanded upwards when it needs more room? Is there a way to do this? Thanks.
Yes, this actually involves two things:
Making the EditText accept multi-line input.
Having its height grow as more text lines are added.
Therefore, to achieve this, you need to set up:
android:inputType="textMultiLine"
android:layout_height="wrap_content"
(Be mindful of the difference between textMultiLine and textImeMultiLine).
The full XML snippet would be:
<EditText
android:layout_width="match_parent"
android:inputType="textMultiLine"
android:layout_height="wrap_content"
android:hint="#string/write_message"
android:textColorHint="#color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:id="#+id/message_input"
android:layout_gravity="center_horizontal"
android:backgroundTint="#color/primary_color"/>
Use both flags: textMultiLine will wrap your input, and textImeMultiLine will provide a break-line key in your keyboard.
<EditText
...
android:layout_height="wrap_content"
android:inputType="textImeMultiLine|textMultiLine"
... />
In my case I have multiline text, but it showed one line and a keyboard:
Though I have already set android:inputType="textCapSentences|textAutoCorrect|textMultiLine", it didn't help. Then I understood that when the keyboard appears in DialogFragment, it collapses the EditText. See DialogFragment and force to show keyboard to show keyboard when DialogFragment shows.
Then I added a short delay (100-300 ms) before showing the keyboard. Now I have:
In AndroidManifest I set android:windowSoftInputMode="adjustResize" for current activity.
I would like to know how to remove the top space/margin of a soft-keyboard.
For clearer picture, checkout the following screenshots:
With space and without space:
The "spacing" you're seeing is the autocomplete suggestion area. If you have an input type set to something as simple as text then you're going to get suggestions from the keyboard. Adding textNoSuggestions to your inputType field will remove the suggestions area.
So for example:
<EditText android:id="#+id/username_field"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions"
android:hint="#string/username" />
Or if you were already using something like textCapWords you can combine them like so:
<EditText android:id="#+id/username_field"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords|textNoSuggestions"
android:hint="#string/username" />
Also, not sure if you are using it but just a heads up, you'll want to use inputType="password" for your password field.
Whatever your inputType is, add |textNoSuggestions to the end of it.