I changed colorOnSurface as specified in the material doc and all properties but this background is still black, how is it possible to modify this element?
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/parameter_gender_selector"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="21dp"
android:hint="#string/genre"
android:textColor="#color/loginButtonColorBackground"
app:boxStrokeColor="#color/black"
app:boxStrokeWidth="0.7dp"
app:hintTextColor="#color/loginButtonColorBackground">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="#+id/actv_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/genre"
android:inputType="none"
android:backgroundTint="#color/transparent"
android:textColor="#color/grayFont"
android:textColorHint="#color/loginButtonColorBackground" />
</com.google.android.material.textfield.TextInputLayout>
Related
I have a TextInputLayout with the style OutlinedBox.ExposedDropdownMenu. I am trying to set the outline color using app:boxStrokeColor but it is not working.
The rest of customizations work, I mean, I can set the boxStrokeWidth correctly and the endIconTint correctly, too.
Any ideas?
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Select an option"
android:textColorHint="#0000ff"
app:endIconTint="#0000ff"
app:boxStrokeColor="#0000ff"
app:boxStrokeWidth="2dp"
app:startIconDrawable="#drawable/ic_baseline_bolt_24">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="20dp"
android:focusable="false"
android:inputType="none"
android:hint="Select an option"/>
</com.google.android.material.textfield.TextInputLayout>
I have implemented a TextInputLayout with a password field in the usual way:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:layout_marginRight="30dp"
android:autofillHints="password"
android:background="#drawable/edit_text_border"
android:hint="#string/password"
android:inputType="textPassword"
android:textColor="#000000"
android:textColorHint="#9e9e9e" />
</com.google.android.material.textfield.TextInputLayout>
I have added this in the dependencies -
implementation 'com.google.android.material:material:1.1.0'
The visibility "eye- icon" is not yet visible. Is there anything that I missed or I did do sommething wrong?
Make sure to use a Material Components theme in your app and use a layout like:
<com.google.android.material.textfield.TextInputLayout
...
android:hint="#string/password"
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText
...
android:inputType="textPassword"
/>
</com.google.android.material.textfield.TextInputLayout>
As you are using an EditText please check the official doc:
Note: A text field is composed of a TextInputLayout and a TextInputEditText as a direct child. Using an EditText as the child might work, but TextInputEditText provides accessibility support for the text field and allows TextInputLayout greater control over the visual aspects of the input text. If an EditText is being used, make sure to set its android:background to #null so that TextInputLayout can set the proper background on it.
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/pass"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="Password"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
The icon doesn't want to show up. I notice that when I add app:passwordToogleEnabled ='true'the height of the textinputlayer moves. However the icon doesnt show up.
<!-- Password Label -->
<com.google.android.material.textfield.TextInputLayout
android:layout_width="340dp"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
app:passwordToggleDrawable="#drawable/visibility_off-24px"
app:passwordToggleTint="#color/mainBlue"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<EditText
android:id="#+id/input_password"
android:background="#drawable/edt_txt_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/sf_compact_display_medium"
android:hint="#string/password"
android:inputType="textPassword"
android:text="sOlUcOm2020" />
</com.google.android.material.textfield.TextInputLayout>
EDIT : My icon was in svg format istead of xml, that's why it didn't show up.
Please try with this code
implementation 'com.google.android.material:material:1.1.0'
and XML
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Passowrd"
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/Password"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
EDIT : Your icon will be in svg format instead of xml, that's why it didn't show up.
I'm creating a password field with custom background using TextInputLayout and AppCompatEditText. Before using Theme.MaterialComponents the the field was fine, but after using it, my AppCompatEditText start showing a line highlight at the bottom. I'm sure it is because of Material styling, but I couldn't figure out which attribute I can use to remove the line and I also not really sure whether it is on the TextInputLayout or the AppCompatEditText.
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
app:hintEnabled="false"
app:passwordToggleEnabled="true">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/passwordInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:layout_marginTop="6dp"
android:layout_marginEnd="#dimen/activity_horizontal_margin"
android:background="#drawable/bg_input_border"
android:fontFamily="#font/opensans_regular"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:paddingTop="13dp"
android:paddingRight="10dp"
android:paddingBottom="13dp"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
You can set boxStrokeWidth value
<com.google.android.material.textfield.TextInputLayout
...
app:boxStrokeWidth="0dp"
...
or Programmatically
textInputLayout.setBoxStrokeWidth(0);
I want to remove dropdown arrow which is created by AutoCompleteTextView when I use TextInputLayout and use Style: ExposedDropdownMenu
Below is my code:
<com.google.android.material.textfield.TextInputLayout
android:layout_marginTop="10dp"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:hint="Marital Status"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:boxStrokeColor="#color/colorPrimaryDark">
<AutoCompleteTextView
android:background="#null"
android:focusable="false"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/edt_marital" />
</com.google.android.material.textfield.TextInputLayout>
If you would like to avoid the dropdown icon just use the app:endIconMode attribute.
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
app:endIconMode="none"
...>
Before and after:
Hello guys, after having searched a lot and found little. I was trying to achieve how I wanted and I wanted to share the experience and result with you.
As the same Material Design documentation says.
A result Image Dropdown Menu similar to a Spinner, following the documentation. Next code:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/txtAnswer"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_top_15dp"
android:layout_marginEnd="10dp"
app:endIconDrawable="#drawable/ic_arrow_down"
app:hintTextAppearance="#style/styleFilterLabelLatoRegular"
app:layout_constraintEnd_toStartOf="#+id/txtAssignedTo"
app:layout_constraintStart_toStartOf="#+id/guideLineBegin"
app:layout_constraintTop_toBottomOf="#+id/txtSearchQuestionnaire">
<AutoCompleteTextView
android:id="#+id/actvTypesAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none"
android:hint="#string/text_answer" />
Now a result as expected from an AutoCompleteTextView Image AutoCompleteTextView. Code xml.
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/txtSearchQuestionnaire"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_top_15dp"
app:endIconMode="none"
app:hintTextAppearance="#style/styleFilterLabelLatoRegular"
app:layout_constraintEnd_toEndOf="#id/guideLineEnd"
app:layout_constraintStart_toStartOf="#+id/guideLineBegin"
app:layout_constraintTop_toBottomOf="#+id/txtPeriodActivation">
<AutoCompleteTextView
android:id="#+id/actvNameQuestionnaire"
style="#style/textAppearanceSettingInputEdittextFilter.Enabled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableEnd="#drawable/ic_search"
android:hint="#string/text_search_name_questionnaire" />
</com.google.android.material.textfield.TextInputLayout>
The only changes were to add the attribute app: endIconMode = "none" in TextInputLayout and in the AutoCompleteTextView the attribute android: drawableEnd="#drawable/ic_search"
Excuse my level of English!!