Material Design TextInputEditText Border Color When Not Activated
I'm placing a TextInputEditText
widget onto a white background. When the fragment first loads, the widget does not have focus. The border around the widget is white (or almost white), so it is invisible on a white background. Here is a screenshot of that widget, drawn on a black background for contrast:
As soon as I tap on the widget, the border becomes that of my primary color, which is exactly what I want. Here is a similar screenshot after the widget is activated.
I'm trying to control these colors through a style, and I've tried everything that I can think of, but I cannot figure out how to adjust that color. Here is my style (feel free to laugh at the various attempts):
<style name="MyTextInputLayout" parent="Base.Widget.MaterialComponents.TextInputLayout">
<item name="android:colorBackground">@android:color/black</item>
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
<item name="android:textColor">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
And finally, the xml of the layout in case it is helpful:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/MyTextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/reg_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
style="@style/MyTextInputEditText"/>
</com.google.android.material.textfield.TextInputLayout>
How can I change this border color when the widget is not active (i.e. does not have focus)?
android material-design
add a comment |
I'm placing a TextInputEditText
widget onto a white background. When the fragment first loads, the widget does not have focus. The border around the widget is white (or almost white), so it is invisible on a white background. Here is a screenshot of that widget, drawn on a black background for contrast:
As soon as I tap on the widget, the border becomes that of my primary color, which is exactly what I want. Here is a similar screenshot after the widget is activated.
I'm trying to control these colors through a style, and I've tried everything that I can think of, but I cannot figure out how to adjust that color. Here is my style (feel free to laugh at the various attempts):
<style name="MyTextInputLayout" parent="Base.Widget.MaterialComponents.TextInputLayout">
<item name="android:colorBackground">@android:color/black</item>
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
<item name="android:textColor">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
And finally, the xml of the layout in case it is helpful:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/MyTextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/reg_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
style="@style/MyTextInputEditText"/>
</com.google.android.material.textfield.TextInputLayout>
How can I change this border color when the widget is not active (i.e. does not have focus)?
android material-design
have you tried givingtextInputLayout
properties totextInputEditText
? likeMaterialComponents.TextInputLayout.OutlinedBox.Dense
– Umair
Nov 21 at 5:05
try setting below properties<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item>
to theme.
– Karan Mer
Nov 21 at 5:06
check this answer stackoverflow.com/a/50818399/7666442
– Nilesh Rathod
Nov 21 at 5:31
add a comment |
I'm placing a TextInputEditText
widget onto a white background. When the fragment first loads, the widget does not have focus. The border around the widget is white (or almost white), so it is invisible on a white background. Here is a screenshot of that widget, drawn on a black background for contrast:
As soon as I tap on the widget, the border becomes that of my primary color, which is exactly what I want. Here is a similar screenshot after the widget is activated.
I'm trying to control these colors through a style, and I've tried everything that I can think of, but I cannot figure out how to adjust that color. Here is my style (feel free to laugh at the various attempts):
<style name="MyTextInputLayout" parent="Base.Widget.MaterialComponents.TextInputLayout">
<item name="android:colorBackground">@android:color/black</item>
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
<item name="android:textColor">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
And finally, the xml of the layout in case it is helpful:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/MyTextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/reg_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
style="@style/MyTextInputEditText"/>
</com.google.android.material.textfield.TextInputLayout>
How can I change this border color when the widget is not active (i.e. does not have focus)?
android material-design
I'm placing a TextInputEditText
widget onto a white background. When the fragment first loads, the widget does not have focus. The border around the widget is white (or almost white), so it is invisible on a white background. Here is a screenshot of that widget, drawn on a black background for contrast:
As soon as I tap on the widget, the border becomes that of my primary color, which is exactly what I want. Here is a similar screenshot after the widget is activated.
I'm trying to control these colors through a style, and I've tried everything that I can think of, but I cannot figure out how to adjust that color. Here is my style (feel free to laugh at the various attempts):
<style name="MyTextInputLayout" parent="Base.Widget.MaterialComponents.TextInputLayout">
<item name="android:colorBackground">@android:color/black</item>
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText">
<item name="android:textColor">@android:color/black</item>
<item name="android:colorBackground">@android:color/black</item>
<item name="android:colorControlActivated">@android:color/black</item>
<item name="android:colorControlNormal">@android:color/black</item>
<item name="android:colorControlHighlight">@android:color/black</item>
<item name="android:backgroundTint">@android:color/black</item>
<item name="android:colorAccent">@android:color/black</item>
</style>
And finally, the xml of the layout in case it is helpful:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
style="@style/MyTextInputLayout">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/reg_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
style="@style/MyTextInputEditText"/>
</com.google.android.material.textfield.TextInputLayout>
How can I change this border color when the widget is not active (i.e. does not have focus)?
android material-design
android material-design
edited Nov 21 at 5:01
Zlytherin
1,3011425
1,3011425
asked Nov 21 at 4:54
Alex
6,98026100177
6,98026100177
have you tried givingtextInputLayout
properties totextInputEditText
? likeMaterialComponents.TextInputLayout.OutlinedBox.Dense
– Umair
Nov 21 at 5:05
try setting below properties<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item>
to theme.
– Karan Mer
Nov 21 at 5:06
check this answer stackoverflow.com/a/50818399/7666442
– Nilesh Rathod
Nov 21 at 5:31
add a comment |
have you tried givingtextInputLayout
properties totextInputEditText
? likeMaterialComponents.TextInputLayout.OutlinedBox.Dense
– Umair
Nov 21 at 5:05
try setting below properties<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item>
to theme.
– Karan Mer
Nov 21 at 5:06
check this answer stackoverflow.com/a/50818399/7666442
– Nilesh Rathod
Nov 21 at 5:31
have you tried giving
textInputLayout
properties to textInputEditText
? like MaterialComponents.TextInputLayout.OutlinedBox.Dense
– Umair
Nov 21 at 5:05
have you tried giving
textInputLayout
properties to textInputEditText
? like MaterialComponents.TextInputLayout.OutlinedBox.Dense
– Umair
Nov 21 at 5:05
try setting below properties
<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item>
to theme.– Karan Mer
Nov 21 at 5:06
try setting below properties
<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item>
to theme.– Karan Mer
Nov 21 at 5:06
check this answer stackoverflow.com/a/50818399/7666442
– Nilesh Rathod
Nov 21 at 5:31
check this answer stackoverflow.com/a/50818399/7666442
– Nilesh Rathod
Nov 21 at 5:31
add a comment |
2 Answers
2
active
oldest
votes
I solved this in two main steps:
First problem I had was that the parent style for my
TextInputLayout
style needed to be changed toWidget.MaterialComponents.TextInputLayout.OutlinedBox
.
Once I figured that out, I traced through the Android xml for that style and got to a file called mtrl_box_stroke_color.xml. This is a selector where the three colors for the standard TextInputLayout border are declared. That file looks like this:
So I copied that and created my own file in the res/color folder that I called edit_text_box_border.xml. I modified the three colors to suit my purposes, ultimately coming up with this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimary" android:state_focused="true"/>
<item android:alpha="0.87" android:color="@color/colorPrimary" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="@color/colorPrimary" android:state_enabled="false"/>
<item android:alpha="0.38" android:color="@color/colorPrimary"/>
</selector>
Then, back in my style, I had to get rid of my many color attempts and add an item for boxStrokeColor that pointed to this file. Here are both styles:
<style name="MyTextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="boxStrokeColor">@color/edit_text_box_border</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox.Dense">
<item name="android:textColor">@android:color/black</item>
</style>
Now, when I run the app, I start out with this:
Which then turns into this when I tap on it:
That's what I was going for, so problem solved. Hope this helps someone.
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
add a comment |
1.
<com.google.android.material.textfield.TextInputLayout
...
style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
app:boxStrokeColor = "@android:color/holo_purple"
//border color when in active status
...
2. add the following in colors.xml file
<color name="mtrl_textinput_default_box_stroke_color">#00ff00</color>
//border color when in inactive status
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405483%2fmaterial-design-textinputedittext-border-color-when-not-activated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I solved this in two main steps:
First problem I had was that the parent style for my
TextInputLayout
style needed to be changed toWidget.MaterialComponents.TextInputLayout.OutlinedBox
.
Once I figured that out, I traced through the Android xml for that style and got to a file called mtrl_box_stroke_color.xml. This is a selector where the three colors for the standard TextInputLayout border are declared. That file looks like this:
So I copied that and created my own file in the res/color folder that I called edit_text_box_border.xml. I modified the three colors to suit my purposes, ultimately coming up with this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimary" android:state_focused="true"/>
<item android:alpha="0.87" android:color="@color/colorPrimary" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="@color/colorPrimary" android:state_enabled="false"/>
<item android:alpha="0.38" android:color="@color/colorPrimary"/>
</selector>
Then, back in my style, I had to get rid of my many color attempts and add an item for boxStrokeColor that pointed to this file. Here are both styles:
<style name="MyTextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="boxStrokeColor">@color/edit_text_box_border</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox.Dense">
<item name="android:textColor">@android:color/black</item>
</style>
Now, when I run the app, I start out with this:
Which then turns into this when I tap on it:
That's what I was going for, so problem solved. Hope this helps someone.
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
add a comment |
I solved this in two main steps:
First problem I had was that the parent style for my
TextInputLayout
style needed to be changed toWidget.MaterialComponents.TextInputLayout.OutlinedBox
.
Once I figured that out, I traced through the Android xml for that style and got to a file called mtrl_box_stroke_color.xml. This is a selector where the three colors for the standard TextInputLayout border are declared. That file looks like this:
So I copied that and created my own file in the res/color folder that I called edit_text_box_border.xml. I modified the three colors to suit my purposes, ultimately coming up with this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimary" android:state_focused="true"/>
<item android:alpha="0.87" android:color="@color/colorPrimary" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="@color/colorPrimary" android:state_enabled="false"/>
<item android:alpha="0.38" android:color="@color/colorPrimary"/>
</selector>
Then, back in my style, I had to get rid of my many color attempts and add an item for boxStrokeColor that pointed to this file. Here are both styles:
<style name="MyTextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="boxStrokeColor">@color/edit_text_box_border</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox.Dense">
<item name="android:textColor">@android:color/black</item>
</style>
Now, when I run the app, I start out with this:
Which then turns into this when I tap on it:
That's what I was going for, so problem solved. Hope this helps someone.
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
add a comment |
I solved this in two main steps:
First problem I had was that the parent style for my
TextInputLayout
style needed to be changed toWidget.MaterialComponents.TextInputLayout.OutlinedBox
.
Once I figured that out, I traced through the Android xml for that style and got to a file called mtrl_box_stroke_color.xml. This is a selector where the three colors for the standard TextInputLayout border are declared. That file looks like this:
So I copied that and created my own file in the res/color folder that I called edit_text_box_border.xml. I modified the three colors to suit my purposes, ultimately coming up with this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimary" android:state_focused="true"/>
<item android:alpha="0.87" android:color="@color/colorPrimary" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="@color/colorPrimary" android:state_enabled="false"/>
<item android:alpha="0.38" android:color="@color/colorPrimary"/>
</selector>
Then, back in my style, I had to get rid of my many color attempts and add an item for boxStrokeColor that pointed to this file. Here are both styles:
<style name="MyTextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="boxStrokeColor">@color/edit_text_box_border</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox.Dense">
<item name="android:textColor">@android:color/black</item>
</style>
Now, when I run the app, I start out with this:
Which then turns into this when I tap on it:
That's what I was going for, so problem solved. Hope this helps someone.
I solved this in two main steps:
First problem I had was that the parent style for my
TextInputLayout
style needed to be changed toWidget.MaterialComponents.TextInputLayout.OutlinedBox
.
Once I figured that out, I traced through the Android xml for that style and got to a file called mtrl_box_stroke_color.xml. This is a selector where the three colors for the standard TextInputLayout border are declared. That file looks like this:
So I copied that and created my own file in the res/color folder that I called edit_text_box_border.xml. I modified the three colors to suit my purposes, ultimately coming up with this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorPrimary" android:state_focused="true"/>
<item android:alpha="0.87" android:color="@color/colorPrimary" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="@color/colorPrimary" android:state_enabled="false"/>
<item android:alpha="0.38" android:color="@color/colorPrimary"/>
</selector>
Then, back in my style, I had to get rid of my many color attempts and add an item for boxStrokeColor that pointed to this file. Here are both styles:
<style name="MyTextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="android:textColorHint">@color/colorPrimary</item>
<item name="android:paddingStart">16dp</item>
<item name="android:paddingEnd">16dp</item>
<item name="boxStrokeColor">@color/edit_text_box_border</item>
</style>
<style name="MyTextInputEditText" parent="ThemeOverlay.MaterialComponents.TextInputEditText.OutlinedBox.Dense">
<item name="android:textColor">@android:color/black</item>
</style>
Now, when I run the app, I start out with this:
Which then turns into this when I tap on it:
That's what I was going for, so problem solved. Hope this helps someone.
answered Nov 21 at 6:06
Alex
6,98026100177
6,98026100177
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
add a comment |
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
This will change the color of all TextImputs in the whole application
– Oscar Méndez
Dec 26 at 7:29
add a comment |
1.
<com.google.android.material.textfield.TextInputLayout
...
style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
app:boxStrokeColor = "@android:color/holo_purple"
//border color when in active status
...
2. add the following in colors.xml file
<color name="mtrl_textinput_default_box_stroke_color">#00ff00</color>
//border color when in inactive status
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
add a comment |
1.
<com.google.android.material.textfield.TextInputLayout
...
style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
app:boxStrokeColor = "@android:color/holo_purple"
//border color when in active status
...
2. add the following in colors.xml file
<color name="mtrl_textinput_default_box_stroke_color">#00ff00</color>
//border color when in inactive status
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
add a comment |
1.
<com.google.android.material.textfield.TextInputLayout
...
style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
app:boxStrokeColor = "@android:color/holo_purple"
//border color when in active status
...
2. add the following in colors.xml file
<color name="mtrl_textinput_default_box_stroke_color">#00ff00</color>
//border color when in inactive status
1.
<com.google.android.material.textfield.TextInputLayout
...
style="@style/Widget.MaterialComponents.TextInputLayout.OutlineBox"
app:boxStrokeColor = "@android:color/holo_purple"
//border color when in active status
...
2. add the following in colors.xml file
<color name="mtrl_textinput_default_box_stroke_color">#00ff00</color>
//border color when in inactive status
answered Nov 21 at 5:43
navylover
3,36521118
3,36521118
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
add a comment |
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
Thanks. Not sure if this would work, but if it does, I would have to apply it to every TextInputLayout individually. My question is about how to do this in a theme.
– Alex
Nov 21 at 6:09
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405483%2fmaterial-design-textinputedittext-border-color-when-not-activated%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
have you tried giving
textInputLayout
properties totextInputEditText
? likeMaterialComponents.TextInputLayout.OutlinedBox.Dense
– Umair
Nov 21 at 5:05
try setting below properties
<item name="colorControlNormal">#c5c5c5</item> <item name="colorControlActivated">@color/accent</item> <item name="colorControlHighlight">@color/accent</item>
to theme.– Karan Mer
Nov 21 at 5:06
check this answer stackoverflow.com/a/50818399/7666442
– Nilesh Rathod
Nov 21 at 5:31