I have this As you can see, toolbar title have to many symbols. I need to increase count of toolbar lines up to 2 when it is deployed
This is how it should be
I tried to set maxlines attribute using style from themes.xml in activity.xml, but it doesn't work.
Code of my activity.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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"
android:fitsSystemWindows="true"
tools:context=".presentation.newsCard.NewsCardActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="170dp"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="#+id/toolbar">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/include_toolbar"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toBottomOf="#+id/include_toolbar">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cardCl"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="#+id/headerTextView"
style="#style/darkGreen20UbuntuBold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="16dp"
android:ellipsize="end"
android:maxLines="2"
android:paddingTop="5dp"
android:text="#string/loading_with_dots"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/dateTextView"
style="#style/gray12UbuntuMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="21dp"
android:maxLines="1"
android:text="#string/loading_with_dots"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/headerTextView" />
<TextView
android:id="#+id/categoryTextView"
style="#style/green12UbuntuMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="11dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:maxLines="1"
android:text="#string/loading_with_dots"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/dateTextView"
app:layout_constraintTop_toBottomOf="#+id/headerTextView" />
<ImageView
android:id="#+id/imageViewContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="6dp"
android:layout_marginEnd="16dp"
android:background="#android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/dateTextView" />
<TextView
android:id="#+id/contentTextView"
style="#style/black14RobotoRegular"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="25dp"
android:text="#string/loading_with_dots"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageViewContainer"
tools:layout_editor_absoluteY="251dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView
android:id="#+id/sourceTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/gray14UbuntuMedium"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="21dp"
android:maxLines="1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardCl"
android:text="#string/source" />
<ImageView
android:id="#+id/sourceImageViewContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/sourceTextView"
app:layout_constraintStart_toStartOf="parent"/>
<TextView
android:id="#+id/sourceNameTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/black14UbuntuMedium"
android:layout_marginStart="16dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="21dp"
android:maxLines="1"
app:layout_constraintStart_toEndOf="#id/sourceImageViewContainer"
app:layout_constraintTop_toBottomOf="#+id/sourceTextView"
android:text="#string/loading_with_dots" />
<TextView
android:id="#+id/authorTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/gray14UbuntuMedium"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="21dp"
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="#id/authorNameTextView"
app:layout_constraintTop_toBottomOf="#+id/cardCl"
android:text="#string/author" />
<TextView
android:id="#+id/authorNameTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="#style/black14UbuntuMedium"
android:layout_marginTop="10dp"
android:layout_marginEnd="18dp"
android:layout_marginBottom="21dp"
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/sourceTextView"
android:text="#string/loading_with_dots" />
<ImageView
android:id="#+id/shareImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="22dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/authorNameTextView"
android:src="#drawable/ic_share"
app:layout_constraintEnd_toStartOf="#+id/addToBookmarkImageView"/>
<ImageView
android:id="#+id/addToBookmarkImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="15dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/authorNameTextView"
android:src="#drawable/ic_bookmark_empty"
app:layout_constraintEnd_toEndOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
In themes.xml I wrote all attributes that I need
Code in themes.xml
<style name="ExpandedAppBar" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#color/green_black</item>
<item name="android:maxLines">2</item>
<item name="fontFamily">#font/ubuntu_bold</item>
</style>
<style name="CollapsedAppBar" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#color/green_black</item>
<item name="android:maxLines">2</item>
<item name="fontFamily">#font/ubuntu_bold</item>
</style>
<style name="ExpandedAppBarPlus1" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">20.5sp</item>
<item name="android:textColor">#color/green_black</item>
<item name="android:maxLines">2</item>
<item name="fontFamily">#font/ubuntu_bold</item>
</style>
<style name="CollapsedAppBarPlus1" parent="#android:style/TextAppearance.Medium">
<item name="android:textSize">16.5sp</item>
<item name="android:textColor">#color/green_black</item>
<item name="android:maxLines">2</item>
<item name="fontFamily">#font/ubuntu_bold</item>
</style>
Related
I have such textview in my layout:
<com.google.android.material.textview.MaterialTextView
android:id="#+id/text_body"
style="#style/TvFontSize"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:justificationMode="inter_word"
android:textColor="#color/gray_color"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/text_header" />
with such style:
<style name="TvFontSize">
<item name="android:autoSizeMaxTextSize">100sp</item>
<item name="android:autoSizeMinTextSize">16sp</item>
<item name="android:autoSizeStepGranularity">2sp</item>
<item name="android:autoSizeTextType">uniform</item>
</style>
and long text is cut off as can see:
full layout is below:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="none">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/bottom_nav_color"
tools:context=".pollsModule.IntroFinalFragment">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/toolbarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:subtitleTextAppearance="#style/Toolbar.SubtitleText"
app:titleTextAppearance="#style/Toolbar.TitleText">
<TextView
android:id="#+id/polls_title"
style="#android:style/TextAppearance.Holo.Widget.ActionBar.Title.Inverse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:textAlignment="center" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<View
android:id="#+id/divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="3dp"
android:background="#color/polls_color"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/toolbarContainer" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/text_header"
style="#style/TvFontSize"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_margin="10dp"
android:textAlignment="center"
android:textColor="#color/gray_color"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/divider" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/text_body"
style="#style/TvFontSize"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="10dp"
android:inputType="textMultiLine"
android:justificationMode="inter_word"
android:singleLine="false"
android:text="dfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjddfjjnfdjnfdjndfjnfdjfjdnjnfdjndfdfjfdjnfnjd"
android:textColor="#color/gray_color"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/text_header" />
<com.google.android.material.button.MaterialButton
android:id="#+id/next_text"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_margin="10dp"
android:layout_marginTop="10dp"
android:maxLines="1"
android:textAllCaps="false"
android:textColor="#color/white"
app:autoSizeMaxTextSize="16sp"
app:autoSizeMinTextSize="6sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform"
app:backgroundTint="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/text_body" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</layout>
I can't imagine how to fix it. I tried to use:
android:inputType="textMultiLine"
android:singleLine="false"
but it didn't help me :(
This attribute affects your TextView. Just remove this attribute from your style part.
<item name="android:autoSizeTextType">uniform</item>
For enabling autoSizeTextType. You have to make your textView height Hardcore means in fixed size like android:layout_height="300dp" or match parent.
I hope it helps.
Thank you #Andrew for your clarification.
your TextView should probably have height set to wrap_content instead of 0dp...
android:layout_height="wrap_content"
I have two themes: the Default one (green) and a red variation.
I set my theme dynamically on the MainActivity, but it looks like a weird mix of both themes.
For some reason only some items change to the new theme and some remain like the old one.
Image
Both, the red and green parts have the tint set to the color accent:
HomeFragment.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="#+id/homeConstraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/homeToolsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/homeSortButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_sort_32"
android:tint="?attr/colorAccent" />
<ImageButton
android:id="#+id/homeCancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_close_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<LinearLayout
android:id="#+id/homeSelectionTools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal">
<ImageButton
android:id="#+id/homeColorAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_color_lens_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<ImageButton
android:id="#+id/homeTagAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_label_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<ImageButton
android:id="#+id/homedeleteAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_delete_forever_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<ImageButton
android:id="#+id/homeSelectButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_done_32"
android:tint="?attr/colorAccent" />
</LinearLayout>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/homeRecycler"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/homeEmptyLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/homeEmptyIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="15dp"
android:contentDescription="Tip"
android:src="#drawable/ic_baseline_inbox_120"
app:tint="?attr/colorAccent" />
<TextView
android:id="#+id/homeEmptyTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito_sans_extrabold"
android:text="What an empty place..."
android:textAlignment="center"
android:textSize="24sp" />
<TextView
android:id="#+id/homeEmptyDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito_sans_bold"
android:text="There are no notes. Try creating a new one"
android:textAlignment="center"
android:textSize="20sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Home Activity
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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:id="#+id/homeConstraint"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.HomeFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/homeToolsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageButton
android:id="#+id/homeSortButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_sort_32"
android:tint="?attr/colorAccent" />
<ImageButton
android:id="#+id/homeCancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_close_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<LinearLayout
android:id="#+id/homeSelectionTools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="end"
android:orientation="horizontal">
<ImageButton
android:id="#+id/homeColorAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_color_lens_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<ImageButton
android:id="#+id/homeTagAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_label_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<ImageButton
android:id="#+id/homedeleteAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_delete_forever_32"
android:tint="?attr/colorAccent"
android:visibility="gone" />
<ImageButton
android:id="#+id/homeSelectButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:background="#android:color/transparent"
android:src="#drawable/ic_round_done_32"
android:tint="?attr/colorAccent" />
</LinearLayout>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/homeRecycler"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/homeEmptyLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/homeEmptyIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="15dp"
android:contentDescription="Tip"
android:src="#drawable/ic_baseline_inbox_120"
app:tint="?attr/colorAccent" />
<TextView
android:id="#+id/homeEmptyTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito_sans_extrabold"
android:text="What an empty place..."
android:textAlignment="center"
android:textSize="24sp" />
<TextView
android:id="#+id/homeEmptyDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/nunito_sans_bold"
android:text="There are no notes. Try creating a new one"
android:textAlignment="center"
android:textSize="20sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
As you can see, homeSortButton from the HomeFragment is red, and newFAB from the MainActivity is green, but both have the same value.
This is my themes.xml file:
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="android:windowBackground">#color/white</item>
<item name="colorAccent">#color/green</item>
<item name="colorPrimary">#color/green</item>
<item name="colorPrimaryVariant">#color/green</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/green</item>
<item name="colorSecondaryVariant">#color/green</item>
<item name="colorOnSecondary">#color/white</item>
<item name="android:overScrollMode">never</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">#android:color/transparent</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
<!-- Customize your theme here. -->
</style>
<style name="Theme.MyApp.Red" parent="Theme.MyApp">
<item name="android:windowBackground">#color/white</item>
<item name="colorAccent">#color/red</item>
<item name="colorPrimary">#color/red</item>
<item name="colorPrimaryVariant">#color/red</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/red</item>
<item name="colorSecondaryVariant">#color/red</item>
<item name="colorOnSecondary">#color/white</item>
<item name="android:overScrollMode">never</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">#android:color/transparent</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
</style>
To set the theme, I call this in OnViewCreated() from my Settings Fragment:
appColorSpinner.onItemSelectedListener = object: AdapterView.OnItemSelectedListener{
override fun onItemSelected(
parent: AdapterView<*>?,
view: View?,
position: Int,
id: Long
) {
var themeColor: Int = 0
when(position){
0 -> {
themeColor = GREEN_COLOR
mContext?.setTheme(R.style.Theme_MyApp)
}
1 -> {
themeColor = RED_COLOR
mContext?.setTheme(R.style.Theme_MyApp_Blue)
}
}
pref?.edit()?.putInt("colorTheme", themeColor)?.apply()
}
I call this in OnCreate from my MainActivity to load the theme:
fun setCurrentTheme(){
val prefs = getSharedPreferences("preferences", Context.MODE_PRIVATE)
val color = prefs.getInt("colorTheme", GREEN_COLOR)
when(color){
GREEN_COLOR -> {
setTheme(R.style.Theme_ZenNotes)
}
RED_COLOR -> {
theme.applyStyle(R.style.Theme_ZenNotes_Red, true)
}
BLUE_COLOR -> {
setTheme(R.style.Theme_ZenNotes_Blue)
}
YELLOW_COLOR -> {
setTheme(R.style.Theme_ZenNotes_Yellow)
}
PURPLE_COLOR -> {
setTheme(R.style.Theme_ZenNotes_Purple)
}
}
}
What could be causing this weird behavior?
Ok, so noob mistake. I had to call setCurrentTheme() before setContentView(...) on my Activity.
Simply, I have a linear layout that separates the screen to 2 pieces from middle and in the first piece I have a constraint layout that contains mountain.png .Because of i set NoActionBar and white for statusBarColor in Themes.xml, as a result above the image there is area that seems white.So I want to remove the white area and scale the image through status bar of the phone.
I tried to remove status bar, it didn't work.
I tried to add android:fitsSystemWindows="true" attribute to .XML file and it didn't work too.
My .xml file
<androidx.constraintlayout.widget.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=".ui.sign_in.telephone.PhoneNumberFragment"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:background="#drawable/mountain">
<TextView
android:id="#+id/baslaText"
android:layout_width="match_parent"
android:gravity="center"
android:layout_marginTop="100dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_height="wrap_content"
android:textSize="38sp"
android:textColor="#color/white"
android:text="Başlayın" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginRight="50dp"
android:layout_marginLeft="50dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/baslaText"
android:layout_marginTop="20dp"
android:textColor="#color/white"
android:textSize="16sp"
android:text="Taşımaya başlamak için kaydolun, ilk \n olarak telefon numaranızı girin"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.cardview.widget.CardView
android:elevation="4dp"
app:cardCornerRadius="14dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/telephoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Telefon numaranızı giriniz"
android:textColor="#color/black"
android:textSize="28sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="match_parent"
android:gravity="center"
android:id="#+id/telephoneText"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:textSize="18sp"
app:layout_constraintRight_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneNumber"
android:text="Taşımaya başlamak için kaydolun, ilk \n olarak telefon numaranızı girin"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/telephoneTag"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="40dp"
android:text="Telefon Numarası"
android:textColor="#color/black"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneText" />
<com.google.android.material.textfield.TextInputLayout
android:elevation="2dp"
app:cardCornerRadius="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/telephoneNumberInput"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneTag"
android:layout_marginTop="20dp"
app:errorEnabled="true"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
>
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/telephoneNumberEditText"
android:layout_width="match_parent"
android:background="#android:color/transparent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:inputType="number"
android:hint="+.. ... ... .. .."
android:maxLength="12"
android:textColor="#color/black"
android:textSize="14sp"
/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginLeft="30dp"
android:layout_marginBottom="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:background="#color/purple_500"
android:backgroundTint="#color/purple_500"
android:text="Başlayın"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#id/telephoneNumberInput" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
My themes.xml file.
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.UI" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/teal_200</item>
<item name="colorPrimaryVariant">#color/white</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
</resources>
write this on your activity onCreate:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
getWindow().setStatusBarColor(Color.TRANSPARENT);
This code piece did the job I desired.
I'm having an issue in my app where the error popup on EditTexts shows but the text is not visible.
It looks something like this:
This happens with all the EditTexts in my app.
Here's an example layout XML
Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/gradient"
android:fitsSystemWindows="true"
tools:context=".ui.onboarding.profile.OnboardingUserProfileActivity">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
app:srcCompat="#drawable/shapes_background" />
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="#+id/form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="80dp"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:layout_marginBottom="20dp">
<ImageView
android:id="#+id/profileImageView"
android:layout_width="160dp"
android:layout_height="160dp"
android:scaleType="fitXY"
android:src="#drawable/user_profile_placeholder"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/cameraImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#android:drawable/ic_menu_camera" />
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/firstnameTvLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_weight="0.33"
android:textColorHint="#color/colorVeryLightGray"
android:theme="#style/AppTheme.WhiteColorAccent"
app:errorTextAppearance="#style/error_appearance">
<android.support.design.widget.TextInputEditText
android:id="#+id/firstnameTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_firstname"
android:inputType="textPersonName"
android:maxLines="1"
android:nextFocusDown="#id/lastnameTv"
android:nextFocusForward="#id/lastnameTv"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHint="#color/colorWhite"
android:theme="#style/AppTheme.WhiteEditText"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/lastnameTvLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_weight="0.33"
android:textColorHint="#color/colorVeryLightGray"
android:theme="#style/AppTheme.WhiteColorAccent">
<android.support.design.widget.TextInputEditText
android:id="#+id/lastnameTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_lastname"
android:inputType="textPersonName"
android:maxLines="1"
android:nextFocusDown="#id/usernameTv"
android:nextFocusForward="#id/usernameTv"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHint="#color/colorWhite"
android:theme="#style/AppTheme.WhiteEditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/usernameTvLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.33"
android:textColorHint="#color/colorVeryLightGray"
android:theme="#style/AppTheme.WhiteColorAccent">
<android.support.design.widget.TextInputEditText
android:id="#+id/usernameTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_username"
android:imeActionId="6"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:maxLines="1"
android:nextFocusDown="#id/nextBtn"
android:nextFocusForward="#id/nextBtn"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHint="#color/colorWhite"
android:theme="#style/AppTheme.WhiteEditText" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/nextBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="16dp"
android:text="#string/next"
android:textStyle="bold"
android:theme="#style/AppTheme.PrimaryButton"
app:layout_anchor="#+id/form"
app:layout_anchorGravity="bottom|center_horizontal" />
</android.support.design.widget.CoordinatorLayout>
And the styles:
<style name="AppTheme.WhiteColorAccent">
<item name="colorAccent">#color/colorWhite</item>
</style>
<style name="AppTheme.WhiteEditText" parent="Widget.AppCompat.EditText">
<item name="android:textColor">#color/colorWhite</item>
<item name="colorControlNormal">#color/colorVeryLightGray</item>
<item name="colorControlActivated">#color/colorWhite</item>
<item name="colorControlHighlight">#color/colorWhite</item>
</style>
Setting error in the activity using firstnameTv.error = "This field can not be empty" (Kotlin)
You need to use
style="#style/AppTheme.WhiteEditText"
Instead of android:theme="#style/AppTheme.WhiteColorAccent"
Now question is why need to use style Instead of android:theme
When you use style it apply will apply only to that view
and When you use android:theme it apply will apply view as well as all of its children.
Read more about What is the difference between style and android:theme attributes?
SAMPLE CODE
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:id="#+id/main_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:background="#color/colorPrimary">
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:visibility="gone" />
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ScrollView
android:id="#+id/form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:fillViewport="true">
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="80dp"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:layout_marginBottom="20dp">
<ImageView
android:id="#+id/profileImageView"
android:layout_width="160dp"
android:layout_height="160dp"
android:scaleType="fitXY"
android:src="#color/colorNavBar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/cameraImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:srcCompat="#android:drawable/ic_menu_camera" />
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/firstnameTvLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_weight="0.33"
android:textColorHint="#color/colorVeryLightGray"
style="#style/AppTheme.WhiteColorAccent"
>
<android.support.design.widget.TextInputEditText
android:id="#+id/firstnameTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="First Name"
android:inputType="textPersonName"
android:maxLines="1"
android:imeOptions="actionNext"
android:nextFocusDown="#id/lastnameTv"
android:nextFocusForward="#id/lastnameTv"
android:textColor="#android:color/white"
android:textColorHint="#color/colorWhite"
style="#style/AppTheme.WhiteEditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/lastnameTvLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_weight="0.33"
android:textColorHint="#color/colorVeryLightGray"
style="#style/AppTheme.WhiteColorAccent">
<android.support.design.widget.TextInputEditText
android:id="#+id/lastnameTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Last Name"
android:inputType="textPersonName"
android:maxLines="1"
android:nextFocusDown="#id/usernameTv"
android:nextFocusForward="#id/usernameTv"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHint="#color/colorWhite"
style="#style/AppTheme.WhiteEditText" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/usernameTvLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="20dp"
android:layout_weight="0.33"
android:textColorHint="#color/colorVeryLightGray"
style="#style/AppTheme.WhiteColorAccent">
<android.support.design.widget.TextInputEditText
android:id="#+id/usernameTv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="user Name"
android:imeActionId="6"
android:imeActionLabel="AB"
android:imeOptions="actionUnspecified"
android:maxLines="1"
android:nextFocusDown="#id/nextBtn"
android:nextFocusForward="#id/nextBtn"
android:singleLine="true"
android:textColor="#android:color/white"
android:textColorHint="#color/colorWhite"
style="#style/AppTheme.WhiteEditText" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/nextBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="16dp"
android:text="Next"
android:textStyle="bold"
app:layout_anchor="#+id/form"
app:layout_anchorGravity="bottom|center_horizontal" />
</android.support.design.widget.CoordinatorLayout>
style
<style name="AppTheme.WhiteColorAccent">
<item name="colorAccent">#color/colorWhite</item>
</style>
<style name="AppTheme.WhiteEditText" parent="Widget.AppCompat.EditText">
<item name="android:textColor">#color/colorWhite</item>
<item name="colorControlNormal">#color/colorVeryLightGray</item>
<item name="colorControlActivated">#color/colorWhite</item>
<item name="colorControlHighlight">#color/colorWhite</item>
</style>
OUTPUT
You need to set the error in TextInputLayout, NOT in TextInputEditText
firstnameTvLayout.setError("Error goes here");
Also make sure you have done
firstnameTvLayout.setErrorEnabled(true);
See the documentation here for more details https://developer.android.com/reference/android/support/design/widget/TextInputLayout
You have to use style instead of android:theme. If you set android:theme to a view group, its children (error pop-up, in this case) will use the same style.
Your code
<android.support.design.widget.TextInputLayout
....
android:theme="#style/AppTheme.WhiteColorAccent"
....>
Change it to
<android.support.design.widget.TextInputLayout
....
style="#style/AppTheme.WhiteColorAccent"
....>
textInputLayout.setErrorEnable(true);
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>
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.
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>