How can i change the color of "hint" in my code?
Because with a dark background, i can't see the text and the place where i need to write...
Thank you so much for your help !
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Veuillez taper son prénom ici"
android:textSize="15dp"
android:layout_gravity="center" />
in a <LinearLayout> android:background="#color/colorBlack"/>
In your XML code you can add android:textColorHint :
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Veuillez taper son prénom ici"
android:textSize="15dp"
android:textColorHint="#ff0000"
android:layout_gravity="center" />
OR you can change the hint color programmatically :
edittext.setHintTextColor(Color.RED);
Add id to EditText to identify tag.
.xml file
<EditText
android:id="#+id/ET_hint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Veuillez taper son prénom ici"
android:textSize="15dp"
android:layout_gravity="center" />
.java file
EditText et_hint = findViewById(R.id.ET_hint);
et_hint.setHintTextColor(getResources().getColor(R.color.white));
Use android:textColorHint="#ff0000" in your xml or edittext.setHintTextColor(Color.BLUE); to set hint color in your Java program grammatically.
if you are using the Material design library. Currently, I am using the version
implementation 'com.google.android.material:material:1.3.0-alpha01'
if you are using the Material design library. Currently, I am using the version
implementation 'com.google.android.material:material:1.3.0-alpha01'
1 - Set color when TextInputLayout is resting.
<item name="android:textColorHint">#color/your_color_hint</item>
2 - Set color when TextInputLayout is floating/focused/tapped.
<item name="hintTextColor">#color/your_color_floating_hint</item>
3 - Set color of the line under TextInputLayout.
<item name="boxStrokeColor">#color/TextViewColor_line</item>
4 - Set color of the error under TextInputLayout.
<item name="boxStrokeErrorColor">#color/colorPrimary</item>
Related
does anyone kn ow how to change MaterialComponents Spinner widget arrow image With AutoCompleteTextView.
code:
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/contractSpinnerContainer"
style="#style/TextInputLayout.FilledBox.Dense.ExposeDropDownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/default_padding"
app:layout_constraintEnd_toStartOf="#+id/guidelineEnd"
app:layout_constraintStart_toStartOf="#+id/guidelineStart"
app:layout_constraintTop_toBottomOf="#+id/registrationLastNameContainer">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Country"
android:imeOptions="actionNext"
android:includeFontPadding="false"
android:inputType="textPersonName"
android:maxLines="1"
android:textColor="#color/ts_black"
android:textSize="#dimen/login_input_text_size" />
</com.google.android.material.textfield.TextInputLayout>
result that want to change:
So with a help of #MatPag answer is:
app:endIconMode="custom"
app:endIconDrawable="#drawable/custom_icon"
and actually on API29 it is working without app:endIconMode="custom", haven't tested on other API's.
You need to set background using theme changes of parent.
Today I have just updated my dependencies of material design
from 1.0.0 to 1.1.0-alpha09
implementation 'com.google.android.material:material:1.1.0-alpha09'
Now i"m getting strange issue in com.google.android.material.textfield.TextInputLayout
Here is my Code
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_10sdp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/emailTextInputEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/hint_enter_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
</com.google.android.material.textfield.TextInputLayout>
after updating the dependencies I'm getting boxed design in my TextInputLayout
Output of above code
if i use implementation 'com.google.android.material:material:1.0.0' I'm getting expected result
Can anybody help me to solve this issue
If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.
UPDATE
I have already tried app:boxBackgroundMode="none" them I'm getting this
,
if i use app:boxBackgroundMode="outline" then getting this
SOLVED
No need to use boxBackgroundMode
You need to add #style/Widget.Design.TextInputLayout in your TextInputLayout
SAMPLE CODE
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/emailTextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_10sdp"
style="#style/Widget.Design.TextInputLayout"
app:errorTextAppearance="#style/error_appearance"
android:textColorHint="#android:color/white">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:id="#+id/emailTextInputEditText"
android:layout_height="wrap_content"
android:backgroundTint="#android:color/white"
android:gravity="center"
android:hint="#string/hint_enter_email"
android:imeOptions="actionNext"
android:textColorHint="#android:color/white"
android:inputType="textEmailAddress"
android:textColor="#android:color/white"
android:textSize="#dimen/_15ssp"/>
</com.google.android.material.textfield.TextInputLayout>
OUTPUT
To revert back to old style with no filed background but only bottom border, one should use following style:
<com.google.android.material.textfield.TextInputLayout
...
style="#style/Widget.Design.TextInputLayout"
....
>
</com.google.android.material.textfield.TextInputLayout>
Using theme Widget.Design.TextInputLayout will generate expected output like below:
Using a material Theme the default style used by the TextInputLayout is #style/Widget.MaterialComponents.TextInputLayout.FilledBox
To obtain something similar just change the background color using the boxBackgroundColor attribute:
<style name="CustomFilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
<item name="boxBackgroundColor">#myColor</item>
</style>
Also use the android:hint="#string/hint_enter_email" in the TextInputLayout not in the TextInputEditText
For me using #style/Widget.Design.TextInputLayout produced undesirable formatting results, specifically alignment issues with the editText box.
I used boxBackgroundMode set to none for awhile, and after updating material design in my project the error icon mentioned started showing. May be a bug (https://issuetracker.google.com/issues/122445449).
For now I'm still setting the boxBackgroundMode to none, and hiding the error icon by setting the color to transparent. This way I keep the material design.
app:boxBackgroundMode="none"
app:errorIconTint="#android:color/transparent"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
app:boxBackgroundMode="none"
app:errorIconTint="#android:color/transparent"
app:hintEnabled="false">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/message_ellipsis"
android:inputType="textCapSentences|textMultiLine"
android:paddingTop="10dp" />
</com.google.android.material.textfield.TextInputLayout>
Set this in your TextInputLayout:
app:boxBackgroundMode="none"
Probably you have set boxBackgroundMode to filled or maybe it's set by default. Just add above line, and this should fix the issue.
Same behavior with com.google.android.material:material:1.3.0
Applying transparent background to TextInputEditText does the tricks.
android:background="#android:color/transparent"
I want to set color of com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner in normal state (i.e. without selecting). I have tried setting colorControlActivated and colorControlNormal, but no luck.
I want to change grey color of spinner as shown in following spinner:
I have set color of editText as follows:
Any type of help would be appreciated. :)
if you have to change grey color of spinner line then use :
app:met_baseColor="#color/Your_color"
and you have to change label color , hint color , font style then use :
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/spDivision"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="36dp"
android:layout_marginRight="36dp"
android:layout_weight="1"
android:hint="#string/DIVISION"
android:letterSpacing="0.1"
android:paddingLeft="4dp"
android:text="#string/DIVISION"
android:textSize="16sp"
app:met_baseColor="#color/outerspace"
app:met_floatingLabel="highlight"
app:met_floatingLabelText="#string/DIVISION"
app:met_floatingLabelTextColor="#color/colorPrimary"
app:met_floatingLabelTextSize="18dp"
app:met_textColor="#color/outerspace"
app:met_textColorHint="#color/colorPrimary" />
Try these attributes:
To change gray line color:
app:met_primaryColor="#color/green" working for me
To change gray text colors:
app:met_textColor="#color/black"
app:met_textColorHint="#color/black"
Use app:met_primaryColor attribute e.g.:
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:met_primaryColor="#F00"/
How do I change the text color of a Button?
try this:
button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR
or
button.setTextColor(0xff0000); //SET CUSTOM COLOR
or
button.setTextColor(Color.parseColor("#ff0000"));
and in xml :
<Button android:id="#+id/mybtn"
android:text="text textx "
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textColor="#ff0000" /> <-- SET TEXT COLOR HERE -->
Use the android:textColor property.
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World"
android:textColor="#android:color/white" />
button.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.red));
this work too
Use: android:textColor="#FFFFFF" on the xml configuration,
or on the activity itself by calling
button.setTextColor(0xFFFFFF);
(FFFFFF is the color white).
For more color codes: here
You can use the android textColor for foreground and for background color of button, text view or any other element see code example
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:background="#ffb6c1"
android:textColor="#fff"
/>
any hexadecimal color code can be written for making interactive view.
change button text color programmatically
button.setTextColor(getResources().getColor(R.color.colorWhite));
An easy way to do this is by defining the color you want in res/values/colors.xml in this way:
<color name="colorCyan">#00BCD4</color>
and the button should look this way:
<Button
android:id="#+id/m_button"
android:text="MY BUTTON"
android:textColor="#color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorCyan"/>
Here's an approach with slightly less code that uses the implied Context of the current Activity.
button.setTextColor(getColor(R.color.colorPrimary));
I have not tested this with all API targets, but it is working for 28.
You can use:
button.setTextColor("green");
or
button.setTextColor(colorcode);
The format is AARRGGBB, so FF0000 is a transparent red. Use FFFF0000 instead.
I built a screen that looks like this:
but if login fails the screen turns out to look like this:
I used EditText and the code looks like this:
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="email"></TextView>
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/username"
android:hint=""
android:textStyle="normal"
android:singleLine="true"
android:inputType="textEmailAddress">
</EditText>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="password">
</TextView>
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/uc_txt_password"
android:hint=""
android:textStyle="normal"
android:singleLine="true"
android:inputType="textPassword">
</EditText>
Any ideas?
Update:
It seems that the bogus display is the way it displays on Ice-cream-sandwich by default. I am using an older version of android (2.2) on which the display looks like the first attached pic.
ICS Introduces a more "open" text layout (look at the gmail app) where edit text's default style lack borders. You should more rigidly define your style to be how you want it on all devices if you don't want it to look like how the device sets it. Perhaps use some 9 patch images and state selector xml files. So if you're setting the background to something like white and not defining any other styles it might be inheriting from Holo.Dark and using this as the edit text bg: https://github.com/android/platform_frameworks_base/blob/master/core/res/res/drawable-hdpi/textfield_default_holo_dark.9.png
Thus, no visible text. Define your style more rigidly, or set your themes better and don't override the other backgrounds.
try to use android selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/editbox_dropdown_background" android:state_focused="false"/>
<item android:drawable="#drawable/editbox_background_focus_yellow" android:state_focused="true"/>
/>
</selector>