user8209152
user8209152

Reputation:

Android Studio text all caps is not working

ScreenShot

As you can see my text all caps property is not ticked, my design tool window shows text in lower case but my emulator does not. The same thing is happening with my phone. Please help.

Here are my xml code: activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.ishansrivastava.a01_06_05_displaying_images_again.MainActivity">

    <include
        layout="@layout/reusable_layout"
        android:layout_width="0dp"
        android:layout_height="83dp"
        tools:layout_constraintTop_creator="1"
        tools:layout_constraintRight_creator="1"
        android:layout_marginStart="3dp"
        android:layout_marginEnd="3dp"
        app:layout_constraintRight_toRightOf="parent"
        android:layout_marginTop="3dp"
        tools:layout_constraintLeft_creator="1"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginLeft="3dp"
        android:layout_marginRight="3dp"
        app:layout_constraintHorizontal_bias="0.0"
        android:id="@+id/include" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="366dp"
        android:layout_height="304dp"
        app:srcCompat="@drawable/levels"
        tools:layout_constraintRight_creator="1"
        tools:layout_constraintBottom_creator="1"
        android:layout_marginStart="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        android:layout_marginEnd="8dp"
        app:layout_constraintRight_toRightOf="parent"
        tools:layout_constraintLeft_creator="1"
        android:layout_marginBottom="16dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        app:layout_constraintHorizontal_bias="0.0" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="158dp"
        android:layout_height="0dp"
        android:layout_marginStart="16dp"
        android:gravity="fill_vertical|center_horizontal"
        android:text="Plain"
        android:textSize="18sp"
        tools:layout_constraintBottom_creator="1"
        tools:layout_constraintLeft_creator="1"
        tools:layout_constraintTop_creator="1"
        app:layout_constraintBottom_toBottomOf="@+id/webView"
        android:layout_marginTop="15dp"
        app:layout_constraintTop_toBottomOf="@+id/include"
        android:layout_marginBottom="14dp"
        app:layout_constraintLeft_toLeftOf="parent"
        android:layout_marginLeft="16dp" />

    <Button
        android:id="@+id/button2"
        android:layout_width="155dp"
        android:layout_height="53dp"
        android:layout_marginEnd="13dp"
        android:layout_marginRight="13dp"
        android:layout_marginTop="2dp"
        android:onClick="onButton2Click"
        android:text="Search the Web"
        app:layout_constraintRight_toRightOf="@+id/include"
        app:layout_constraintTop_toBottomOf="@+id/include"
        tools:layout_constraintRight_creator="1"
        tools:layout_constraintTop_creator="1"
        tools:textAllCaps="false" />

    <WebView
        android:id="@+id/webView"
        android:layout_width="0dp"
        android:layout_height="35dp"
        tools:layout_constraintLeft_creator="1"
        tools:layout_constraintRight_creator="1"
        tools:layout_constraintTop_creator="1"
        app:layout_constraintRight_toRightOf="@+id/button2"
        android:layout_marginTop="9dp"
        app:layout_constraintTop_toBottomOf="@+id/button2"
        app:layout_constraintLeft_toLeftOf="@+id/button2" />

</android.support.constraint.ConstraintLayout>

reusable_layout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="368dp"
    android:layout_height="495dp"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    tools:layout_editor_absoluteX="8dp"
    tools:layout_editor_absoluteY="8dp"
    tools:showIn="@layout/content_main">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Pepperoni" />

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Extra Cheese" />
    </LinearLayout>

    <Button
        android:id="@+id/button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="onButtonClick"
        android:text="Show Image"
        tools:textAllCaps="false" />

</LinearLayout>

Upvotes: 2

Views: 4301

Answers (5)

Fazal
Fazal

Reputation: 122

Attributes like

android:inputType, android:SingleLine

nullifies effect of textAllCaps.

Take note

Upvotes: 0

Willey Hute
Willey Hute

Reputation: 1078

In my case, in theme, I have set

<style name="TextAppearance.WD.Headline6" parent="TextAppearance.MaterialComponents.Headline6">
    ...
    <item name="textAllCaps">true</item>
    ...
</style>

But in one widget, I need to get every other attributes of Headline6 except textAllCaps attr.

So I am using in that widget as,

<TextView
...
android:textAppearance="?attr/textAppearanceHeadline6"
android:textAllCaps="false"
.../>

But that won't work, the theme attribute overrides the layout attribute and the widget shows all the text in caps.

The solution is to apply the attribute through code as,

binding.textViewHeadline6.isAllCaps = false

This works!

Upvotes: 0

Navang Shah
Navang Shah

Reputation: 1

edittext.setFilters(new InputFilter[] {new InputFilter.AllCaps()});

Upvotes: 0

Sunisha Guptan
Sunisha Guptan

Reputation: 1605

tools:textAllCaps="false" change this in to android:textAllCaps="false"

For your another comment,please check with this,

    <style name="AppTheme" parent="AppBaseTheme">
    <item name="android:buttonStyle">@style/Button</item>
</style>

<style name="Button" parent="Widget.AppCompat.Button">
    <item name="android:textAllCaps">false</item>
</style>

The button text might be transformed to uppercase by your app's theme that applies to all buttons. Check your themes / styles files for setting the attribute android:textAllCaps.

Upvotes: 3

ND1010_
ND1010_

Reputation: 3841

try this in your button

android:textAllCaps="false"

if it don't work than try this my friend than this

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:buttonStyle">@style/Button</item>
</style>

<style name="Button" parent="Widget.AppCompat.Button">
    <item name="android:textAllCaps">false</item>
</style>

Upvotes: 0

Related Questions