How to style DatePicker on Android - android

I have date picker which I've tried to customize to a different style but to no avail.
I want to show a DatePicker and not a DatePickerDialog.
In the layout design tab on Android Studio, the DatePicker's background color is black and the text color is white.
However, the datePicker occupies space on the device screen but is not visible.
I've also tried to change the AppTheme.
The DatePicker code is below:
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.AgeFragment">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/roboto_medium"
android:text="Sign up"
android:textColor="#color/titleBlack"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
app:srcCompat="#drawable/ic_baseline_arrow_back_24"
app:layout_constraintBottom_toBottomOf="#+id/textView"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/textView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:fontFamily="#font/roboto_medium"
android:text="When's your birthday?"
android:textColor="#color/titleBlack"
android:textSize="20sp"
app:layout_constraintStart_toStartOf="#+id/imageView"
app:layout_constraintTop_toBottomOf="#+id/textView" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif-condensed"
android:text="Your birthday won't be shown publicly"
android:textColor="#7A7474"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="#+id/textView2"
app:layout_constraintTop_toBottomOf="#+id/textView2" />
<DatePicker
android:id="#+id/date_picker2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:calendarViewShown="false"
android:calendarTextColor="#android:color/holo_green_dark"
android:background="#android:color/holo_red_dark"
android:datePickerMode="spinner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView3"
tools:targetApi="lollipop" />
<Button
android:id="#+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:background="#color/pinkBtnBackground"
android:fontFamily="sans-serif-medium"
android:text="Next"
android:textAllCaps="false"
android:textColor="#android:color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/date_picker2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#android:color/transparent</item>
<item name="colorPrimaryDark">#android:color/transparent</item>
<item name="colorAccent">#android:color/transparent</item>
<item name="android:background">#android:color/white</item>
<item name="android:textColor">#color/textColor</item>
<item name="android:datePickerStyle">#style/DatePickerStyle</item>
</style>
<style name="DatePickerStyle">
<item name="android:calendarTextColor" tools:ignore="NewApi">#android:color/holo_green_dark</item>
<item name="backgroundColor">#android:color/holo_red_dark</item>
</style>
The result is still the same. I've searched for answers but none provides a solution to this problem.
Any help or reference to a documentation that provide an explanation would be highly appreciated.

Try removing <item name="android:background">#android:color/white</item> from the style. It is messing with your current Layout

Related

How can I change maxlines attribute of toolbar title in CollapsingToolbarLayout?

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>

Android - Scale Image to status bar of the phone

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.

unable to display background color in activity

this is my XML file. I am having trouble while running my app. I have already created same GUI for registration activity but getting problem while designing login activity. I have declared tools:background = "#color/colorPrimary" but unable get colorPrimary . what should I do to solve this error. why I am getting this error. Help me.
<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:background="#color/colorPrimary"
tools:context="com.example.pratikrathi.registerapp.RegisterActivity">
<EditText
android:id="#+id/reg_email_text"
android:layout_width="0dp"
android:layout_height="54dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="200dp"
android:backgroundTint="#android:color/white"
android:ems="10"
android:hint="#string/email_hint"
android:inputType="textEmailAddress"
android:paddingVertical="16dp"
android:textColor="#android:color/white"
android:textColorHint="#color/whiteTransparentHalf"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_progress" />
<EditText
android:id="#+id/reg_password_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="#android:color/white"
android:ems="10"
android:hint="#string/password_hint"
android:inputType="textPassword"
android:paddingVertical="16dp"
android:textColor="#android:color/white"
android:textColorHint="#color/whiteTransparentHalf"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/reg_email_text" />
<Button
android:id="#+id/login_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:backgroundTint="#color/colorAccent"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:text="#string/login_btn_text"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/reg_password_text" />
<Button
android:id="#+id/login_reg_btn"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:backgroundTint="#android:color/white"
android:paddingBottom="20dp"
android:paddingTop="20dp"
android:text="#string/login_reg_btn_text"
android:textAllCaps="false"
android:textColor="#color/colorAccent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent" />
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="invisible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Simply change tools:background="#color/colorPrimary" to android:background="#color/colorPrimary",
since tools is used for visibility inside android studio in preview
add following code, where you want to apply backgroung:
style="#style/style1"
values/style.xml
<style name="style1">
<item name="android:background">#drawable/custom_color</item>
</style>
drawable\custom_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#color/custom_color" />
</shape>
</item>
values\colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="custom_color">#123456</color>
</resources>

Constraint Layout with transparency and elevation

I have 10 TextViews inside 1 Constraint Layout. What i would like to achieve is to have the Constraint Layout have some elevation to make it seem like all 10 textviews are basically above my background. But i would like to keep the background of my layout to take the background of the phone so have the Constraint layout have a transparent background. Any way i can achieve this?
I saw various posts here about this but they actually want the layout colored in and not transparent and that is where this one differs from theirs.
I have tried way to do it with shapes using a rectangle but the shadow of the elevation will only appear if i make the rectangle visible.... and not transparent.
<android.support.constraint.ConstraintLayout
android:id="#+id/topBorder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintTop_toBottomOf="#id/tvTitle">
<TextView
android:id="#+id/tvIon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="5dp"
android:text="#string/Ion"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="#+id/tvIonResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="5dp"
android:text="#string/ResultPlaceHolder"
android:textColor="#android:color/black"
android:textSize="18sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/tvSn1_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:text="#string/sn1_1"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvIon" />
<TextView
android:id="#+id/tvSn1_Result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="#string/ResultPlaceHolder"
android:textColor="#android:color/black"
android:textSize="18sp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="#+id/tvIonResult" />
<TextView
android:id="#+id/tvSn1_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:text="#string/sn1_3"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvSn1_1" />
<TextView
android:id="#+id/tvSn1_3_Result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="10dp"
android:text="#string/ResultPlaceHolder"
android:textColor="#android:color/black"
android:textSize="18sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvSn1_Result" />
<TextView
android:id="#+id/tvSn2_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="10dp"
android:text="#string/sn2_1"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvSn1_3" />
<TextView
android:id="#+id/tvSn2_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="#string/sn2_3"
android:textColor="#android:color/black"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="#+id/tvSn2_1" />
<TextView
android:id="#+id/tvSn2_3_Result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="#string/ResultPlaceHolder"
android:textColor="#android:color/black"
android:textSize="18sp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="#+id/tvSn2_1_Result" />
<TextView
android:id="#+id/tvSn2_1_Result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginTop="10dp"
android:text="#string/ResultPlaceHolder"
android:textSize="18sp"
android:textColor="#android:color/black"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tvSn1_3_Result" />
</android.support.constraint.ConstraintLayout>
This is my xml for what i tried
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="#00ffffff"/>
<stroke android:color="#00000000"/>
</shape>
</item>
</layer-list>
if you want to create a transparent activity on android
Add the following style in your res/values/styles.xml
file Here’s a complete file:
<style name="AppTheme.Transparent" paren="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
then In the AndroidManifest.xml:
<activity
android:name=".WhateverNameOfTheActivityIs"
android:theme="#style/AppTheme.Transparent">
</activity>
If you do not want your layout to be completely transparent
then in your layout add this to ConstraintLayout
android:background="#80000000"
If you add this line to the Constraint Layout xml it will become transparent: android:background="#android:color/transparent". This will make the background see through and show what ever is bellow or overlapping.

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>
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>

Categories

Resources