Cannot lower case button text in android studio
You could add android:textAllCaps="false"
to the button.
The button text might be transformed to uppercase by your app's theme that applies to all buttons. Check themes / styles files for setting the attribute android:textAllCaps
.
Check upper case,lower case, length and symbols on text change edittext
you can check password using this methods:
private static boolean hasLength(CharSequence data) {
return String.valueOf(data).length() >= 8;
}
private static boolean hasSymbol(CharSequence data) {
String password = String.valueOf(data);
return !password.matches("[A-Za-z0-9 ]*");
}
private static boolean hasUpperCase(CharSequence data) {
String password = String.valueOf(data);
return !password.equals(password.toLowerCase());
}
private static boolean hasLowerCase(CharSequence data) {
String password = String.valueOf(data);
return !password.equals(password.toUpperCase());
}
then addTextChangedListener will be like this:
pass_word.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(pass_word.getText().toString().length() > 0){
if(hasLength(pass_word.getText().toString())){
check_length.setChecked(true);
}else{
check_length.setChecked(false);
}
if(hasSymbol(pass_word.getText().toString())){
check_symbol.setChecked(true);
}else{
check_symbol.setChecked(false);
}
if(hasUpperCase(pass_word.getText().toString())){
check_upper.setChecked(true);
}else{
check_upper.setChecked(false);
}
if(hasLowerCase(pass_word.getText().toString())){
check_lower.setChecked(true);
}else{
check_lower.setChecked(false);
}
}else{
check_lower.setChecked(false);
check_upper.setChecked(false);
check_length.setChecked(false);
check_symbol.setChecked(false);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
Android tab titles lowercase
As no solution worked for me, finally I solved it like this:
In my styles.xml to <style name="Base.Widget.Design.TabLayout" parent="@android:style/Theme.Holo">
i just put
<item name="android:actionBarTabTextStyle">@style/My.TabText.Style</item>
and then below:
<style name="My.TabText.Style" parent="@android:style/Widget.Holo.ActionBar.TabText">
<item name="android:textAllCaps">false</item>
</style>
This is the only solution that works for me!
So the point was to add android:actionBarTabTextStyle
and not tabTextAppearance
How do I include lowercase characters in the text on a button using Android API 10?
Step #1: Open app/src/main/res/values/styles.xml
. This should show a stub custom theme, inheriting from a Theme.AppCompat
-based theme, given your symptoms.
Step #2: Add a new <style>
to that file:
<style name="MixedCaseButton" parent="Widget.AppCompat.Button">
<item name="textAllCaps">false</item>
</style>
You will notice that this references textAllCaps
. The native implementation of textAllCaps
is new to API Level 14. This theme is using the backport of textAllCaps
supplied by appcompat-v7
, which you are using, given your symptoms.
Step #3: Add this element to your custom theme, the one that already existed in the styles.xml
file:
<item name="buttonStyle">@style/MixedCaseButton</item>
This will give you an overall styles.xml
file resembling:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="buttonStyle">@style/MixedCaseButton</item>
</style>
<style name="MixedCaseButton" parent="Widget.AppCompat.Button">
<item name="textAllCaps">false</item>
</style>
</resources>
(though the other contents of the pre-existing style resource may vary somewhat)
Step #4: Run your app, and you will see the button appear in mixed case. Please note that this violates the Material Design aesthetic.
Replacing upper-case with upper-case and lower-case with lower-case
Actually you are replacing original text with searchText
, and by using (?i)
replace function works case-insensitive.
If I want to do this, I prefer to use SpannableString like bellow:
String originalText = "Your original text";
Spannable wordToSpan = new SpannableString(originalText);
originalText = originalText.toLowerCase();
searchText = searchText.toLowerCase();
int length = searchText.length();
int index = originalText.indexOf(searchText);
while (index >= 0) {
wordToSpan.setSpan(new ForegroundColorSpan(Color.BLUE), index, index + length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = originalText.toLowerCase().indexOf(searchText, index + length);
}
txtV.setText(wordToSpan);
How to make com.google.android.material.button.MaterialButton text lower case
You need to set both textAllCaps
and android:textAllCaps
to false to disable all capitalize setting.
Related Topics
Super.Onbackpressed() and Finish() Exits the App
How to Create a Video from an Array of Images in Android
How to Get Data from Edit Text in a Recyclerview
Charging Animation for Android
How to Open Fragment from Recyclerview Adapter
Android Q, Programmatically Connect to Different Wifi Ap for Internet
Showing Thumbnail for Link in Whatsapp || Og:Image Meta-Tag Doesn't Work
Install_Failed_User_Restricted:Android Studio Using Redmi 4 Device
Android - Edittext Not Showing Any Text
How to Make Buttons Align At the Middle - Android Studio
Recyclerview No Adapter Attached; Skipping Layout
How to Tell If a View Is Visible on Screen in Android
Fragment Is Not Being Replaced But Put on Top of the Previous One
How to Post Array in Retrofit Android
How to Disable Cache in Android Webview
Architecture Components: Observer Keep Observing Even After Removing It on Ondestroy