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.
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 ShapeableImageView, and I set corner size. Applying rounded is successful but, In out of rounded It shows black background.
Can you tell me What's the problem?
I searched about it, someone say it's just preview. But It's showing when I run app too.
Like this. I wanna remove the black one.
My layout Xml.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<ImageButton
android:id="#+id/btnPinAddNewEventFolder"
android:layout_width="168dp"
android:layout_height="168dp"
android:background="#drawable/radius_add_pin_folder"
android:elevation="2dp"
android:scaleType="centerCrop"
android:src="#drawable/btn_add_pin_folder"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/clPinEventDefaultFolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
>
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/pinEventDefaultFolderThumbnail"
android:layout_width="168dp"
android:layout_height="168dp"
android:src="#color/gray6"
android:scaleType="centerCrop"
app:shapeAppearanceOverlay="#style/RoundPinFolder"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
<ImageView
android:id="#+id/ImgEventDefaultFolderNull"
android:layout_width="69dp"
android:layout_height="65dp"
android:background="#drawable/ic_folder"
android:backgroundTint="#color/gray5"
app:layout_constraintBottom_toBottomOf="#+id/pinEventDefaultFolderThumbnail"
app:layout_constraintEnd_toEndOf="#+id/pinEventDefaultFolderThumbnail"
app:layout_constraintStart_toStartOf="#+id/pinEventDefaultFolderThumbnail"
app:layout_constraintTop_toTopOf="#+id/pinEventDefaultFolderThumbnail" />
<TextView
android:id="#+id/txtDefaultEventPinFolder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="#font/nanumsquare_b"
android:text="이벤트 기본 폴더"
android:textAlignment="textStart"
android:textColor="#color/black"
android:textSize="12sp"
app:layout_constraintEnd_toStartOf="#+id/tvDefaultFolderPinNum"
app:layout_constraintStart_toStartOf="#+id/pinEventDefaultFolderThumbnail"
app:layout_constraintTop_toBottomOf="#+id/pinEventDefaultFolderThumbnail"
/>
<TextView
android:id="#+id/tvDefaultEventFolderPinNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="#font/nanumsquare_b"
android:text="num"
android:textAlignment="textEnd"
android:textColor="#color/gray3"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="#+id/pinEventDefaultFolderThumbnail"
app:layout_constraintTop_toBottomOf="#+id/pinEventDefaultFolderThumbnail" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="24dp"
app:layout_constraintTop_toBottomOf="#+id/constraintLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:orientation="vertical"
>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rvEventPinFolder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
style code
<style name="RoundPinFolder">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">10%</item>
</style>
Use padding inside ShapeableImageView like
android:padding="0.5dp"
Example
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/imgBanner"
android:layout_width="0dp"
app:shapeAppearanceOverlay="#style/roundedImageViewRounded"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:padding="0.5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
In your manifest file, in the application tag. set
android:hardwareAccelerated="true"
By default it is false
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);
I'm having some issues inside a constraint layout where i have a TextView which supports multiple lines. When the TextView is expanded it overlaps with other components inside the constraint layout. Below is the XML layout that i'm using and a GIF to demonstrate.
Any help would be much appreciated.
Demonstration -> https://puu.sh/xPFSF/3f6711a68f.gif
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:background="#color/activity_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<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:focusableInTouchMode="true"
android:layout_height="0dp">
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/leftGuideline"
app:layout_constraintGuide_begin="20dp"
android:orientation="vertical"/>
<android.support.constraint.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/rightGuideline"
app:layout_constraintGuide_end="20dp"
android:orientation="vertical"/>
<TextView
android:id="#+id/subject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/subject"
android:layout_marginTop="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
<EditText
android:id="#+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="#string/your_message"
android:layout_marginTop="20dp"
android:minLines="2"
app:layout_constraintTop_toBottomOf="#id/subject"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
<Button
android:id="#+id/sendMessageButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="#string/send_message"
style="#style/button_main"
app:layout_constraintVertical_bias="1"
app:layout_constraintTop_toBottomOf="#id/message"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintBottom_toTopOf="#+id/saveDraftButton"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
<TextView
android:id="#+id/saveDraftButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/save_draft"
android:layout_marginBottom="10dp"
android:drawableStart="#drawable/icon_arrow"
android:gravity="center_vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
Edit: Removed RecyclerView as it wasn't necessary.
As requested, button_main style:
<style name="button_main" parent="#style/button">
<item name="android:textColor">#color/button_main_stateful_text</item>
<item name="android:background">#drawable/primary_action_button</item>
<item name="android:textSize">#dimen/h5_size</item>
<item name="android:textAllCaps">false</item>
</style>
button_main_stateful_text & primary_action_button are just two selectors that switch between colours.
scottazord adding
app:layout_constraintBottom_toTopOf="#+id/sendMessageButton"
to EditText should solve your problem.
the EditText full code is
<EditText
android:id="#+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="your message"
android:layout_marginTop="20dp"
android:minLines="2"
app:layout_constraintTop_toBottomOf="#id/subject"
app:layout_constraintStart_toStartOf="#id/leftGuideline"
app:layout_constraintEnd_toEndOf="#id/rightGuideline"
app:layout_constraintBottom_toTopOf="#+id/sendMessageButton"/>
now this should solve your issue
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>