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);
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 am using material design 'com.google.android.material:material:1.3.0' in my Android app ( just to add password toggle for password field). I don't want other material features being included to my EditText.As you can see on the screenshot, green line appears when PasswordEditText is touched. How can i get it rid of and leave only password toggle among material design features?
I tried to use
app:boxBackgroundMode="none" app:boxStrokeWidth="0dp" app:boxStrokeWidthFocused="0dp" app:boxStrokeColor="#android:color/transparent"
to remove the line but it didn't help.
Here is XML of Material design EditText:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/editTextTextPersonName2"
android:layout_width="match_parent"
android:layout_marginTop="36dp"
android:layout_marginRight="46dp"
android:layout_marginLeft="46dp"
android:paddingLeft="5dp"
android:layout_height="wrap_content"
app:hintEnabled="false"
app:boxBackgroundMode="none"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:boxStrokeColor="#android:color/transparent"
android:ems="10"
android:background="#drawable/edit_text_background"
app:passwordToggleEnabled="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/editTextTextPersonName">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
app:textInputLayoutFocusedRectEnabled="false"
android:hint="Parol"
android:textSize="20sp"
android:drawableStart="#drawable/ic_baseline_security_24"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:inputType="textPassword"
android:drawablePadding="5dp"/>
</com.google.android.material.textfield.TextInputLayout>
Set android:background="#null in the TextInputEditText
Set app:boxStrokeWidth="0dp" in the TextInputLayout and that will hide the line (stroke).
Or you can change the line color to match with the edittext container background color as you want, set app:boxStrokeColor="#color/white" in the TextInputLayout
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>
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>
I need [top|start] hint text an TextInputEditText..
I use android:gravity="top|start" hint text still in center, but the text content is correct (top start)
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="200">
<com.google.android.material.textfield.TextInputEditText
android:text="#={textProg.textProg.text}"
android:hint="Hint Text"
android:layout_width="match_parent"
android:layout_height="100dp"
android:inputType="textMultiLine"
android:gravity="top|start"
android:maxLength="200"
android:textColor="#drawable/edit_text_color"/>
</com.google.android.material.textfield.TextInputLayout>
i don't know why your code doesn't work with you it work with me , but you can try this i hope it work .
<com.google.android.material.textfield.TextInputLayout
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:counterEnabled="true"
app:counterMaxLength="200">
<com.google.android.material.textfield.TextInputEditText
android:text="#={textProg.textProg.text}"
android:hint="Hint Text"
android:layout_width="match_parent"
android:layout_height="100dp"
android:inputType="textMultiLine"
android:ellipsize="start"
android:gravity="top"
android:maxLength="200"
/>
</com.google.android.material.textfield.TextInputLayout>
why you not try by adding this android:ellipsize="top|start"
Probably it's an issue related to material design library. I have checked with different version and found different scenarios for same layout. Among them below version gives me the result that you want to achieve.
implementation 'com.google.android.material:material:1.2.0-alpha01'
Output: