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.
Related
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?
I am using TextInputLayout from Google material design library (version 1.4.0-alpha02).
If I set this property in the XML:
app:endIconMode="password_toggle"
A button is displayed to toggle between the password being displayed as plain-text or disguised.
Now if I try to do the same programmatically, as reported in the documentation I call
myTextInputLayout.endIconMode = END_ICON_PASSWORD_TOGGLE
The button appears correctly, but tapping it has no effect.
I tried to play a bit with all the methods and I found out that doing this:
myTextInputLayout.clearOnEndIconChangedListener()
myTextInputLayout.endIconMode = END_ICON_PASSWORD_TOGGLE
makes the button work: the content of the editText actually changes from plain-text to disguised, but the button stay the same. The icon is supposed to change depending on the state.
This is the layout I am using:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/myTextInputLayout"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:textColorHint="?android:textColorSecondary"
app:boxStrokeColor="#drawable/text_input_stroke_selector"
app:boxStrokeWidth="1dp"
app:endIconTint="?android:textColorSecondary"
app:errorIconDrawable="#null"
app:hintTextColor="?android:textColorSecondary">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:textCursorDrawable="#null" />
</com.google.android.material.textfield.TextInputLayout>
Any idea?
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 an EditText which I want to be editable and selectable, just like any other EditText. My theme is
...Light.NoActionBar
so I need an extra ActionBar for the Copy/Paste etc. when the text is selected.
So I use
editText.setTextIsSelectable()
and it works, but when I enable it, the textView becomes ineditable!
To make it editable again, I use the following
editText.setFocusableInTouchMode(true);
editText.setFocusable(true);
editText.setClickable(true);
editText.setLongClickable(true);
but it doesn't help! Also, it doesn't make a difference whether I assign these tags in the .xml or in the code, I tried that...
I guess the solution is pretty simple, but the API docs and google didn't tell me how to make it editable again... It seems like noone ever had that problem before
EDIT:
xml:
<EditText
android:id="#+id/etMitspieler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="Players"
android:inputType="textPersonName"
android:text="test"
android:textColor="#android:color/background_light"
some constraint stuff... />
One of the users of my app is having an issue where the text he enters in the EditText elements of my app is white, which effectively renders it invisible against a white background. He's the only user experiencing this issue, and it's only happening to him in my app.
As an example, here's the code for one of my EditText elements:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/usernameTextBox"
android:imeOptions="actionDone"
android:singleLine="true"/>
There are dozens of these in my app, and all are essentially coded the same. Any ideas why this might be happening?
Every android distribution can overwrite default colors for widget. Therefore, if you want all of your EditText to look the same you should explicitly set their background and text color like so:
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/usernameTextBox"
android:imeOptions="actionDone"
android:singleLine="true"
android:background="#FFFFFF"
android:textColor="#000000"/>
To ensure that the text colour being displayed correctly, strictly set the textColor attribute for each declared TextView like so android:textColor="#android:color/black"