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
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"
Solved
I have a scroll view that has a Constraint Layout layout inside of it. I Have a button that is constraint to the bottom of the table but it seems to change the background below the table to gray. all other widgets that I have added do not have the same problem.
Screenshot of problem
I removed the inner code of the table as its not need
<ScrollView 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">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/gaapic" />
<androidx.cardview.widget.CardView
android:id="#+id/homecard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp"
app:cardBackgroundColor="#color/white"
app:cardCornerRadius="15dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/imageView3">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="12dp"
android:padding="12dp"
android:text="#string/recent_news"
android:textColor="#color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="#+id/tvhomePageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="9"
android:gravity="center"
android:text="#string/publish_date"
android:textColor="#color/black"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:lineSpacingMultiplier="1.5"
android:padding="12dp"
android:text="#string/in_news"
android:textSize="13sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#android:color/white"
android:elevation="90dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homecard">
<!-- Table Heading -->
<TableRow android:background="#color/teal_200">
</TableLayout>
<TextView
android:id="#+id/tvTimeCheck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.092"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableLayout"
app:layout_constraintVertical_bias="0.589" />
<Button
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Live"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/tableLayout"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
Try adding the following to either your ScrollView or ConstraintLayout:
android:background="#android:color/white"
Solved:
I solved my problem by putting the table inside of another Constraint Layout. I don't know if that is best practice but it works for now. Thank you #Shn_Android_Dev
Have you tryed to add .setBackgroundDrawable(null) to you button inside your class?
Example:
yourButton.setBackgroundDrawable(null);
I have a card view layout of having one imageView on left side and two textviews aligned vertically placed in right of imageview. Right now I am getting issue as text is cutting in right side of screen in one of textview. Below is XML layout that I am using.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/spacing_large"
tools:context=".ui.profile.GroupProfileActivity"
android:background="#android:color/background_light">
<com.google.android.material.card.MaterialCardView
android:id="#+id/groupCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="#dimen/spacing_normal"
app:cardElevation="2dp"
android:elevation="2dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/groupImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="#+id/layoutGroup"
app:layout_constraintBottom_toBottomOf="#+id/layoutGroup"
app:layout_constraintStart_toStartOf="#+id/layoutGroup"
app:srcCompat="#drawable/ic_group_black_24dp"
android:paddingLeft="#dimen/spacing_normal"/>
<!-- Donor type layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutGroupView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintLeft_toRightOf="#+id/groupImageView"
app:layout_constraintTop_toTopOf="#+id/layoutGroup"
android:layout_marginLeft="#dimen/spacing_normal">
<TextView
android:id="#+id/tvGroupName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Demo"
android:textSize="#dimen/font_normal"
app:layout_constraintTop_toTopOf="#+id/layoutGroupView"
app:layout_constraintStart_toStartOf="#+id/layoutGroupView"/>
<TextView
android:id="#+id/tvGroupNameLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/group_label"
android:textSize="#dimen/font_normal"
app:layout_constraintTop_toBottomOf="#+id/tvGroupName"
app:layout_constraintStart_toStartOf="#+id/layoutGroupView"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/mobileCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/groupCardView"
android:layout_marginTop="#dimen/spacing_large"
app:cardElevation="2dp"
android:elevation="2dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/phoneImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="#+id/layoutPhone"
app:layout_constraintBottom_toBottomOf="#+id/layoutPhone"
app:layout_constraintStart_toStartOf="#+id/layoutPhone"
app:srcCompat="#drawable/ic_phone_black_24dp"
android:paddingLeft="#dimen/spacing_normal"/>
<!-- Donor type layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutPhoneView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintLeft_toRightOf="#+id/phoneImageView"
app:layout_constraintTop_toTopOf="#+id/layoutPhone"
android:layout_marginLeft="#dimen/spacing_normal">
<TextView
android:id="#+id/tvPhone"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="Demo"
android:textSize="#dimen/font_normal"
app:layout_constraintTop_toTopOf="#+id/layoutPhoneView"
app:layout_constraintStart_toStartOf="#+id/layoutPhoneView"/>
<TextView
android:id="#+id/tvPhoneLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/phone_label"
android:textSize="#dimen/font_normal"
app:layout_constraintTop_toBottomOf="#+id/tvPhone"
app:layout_constraintStart_toStartOf="#+id/layoutPhoneView"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/addressCardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="#+id/mobileCardView"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="#dimen/spacing_large"
app:cardElevation="2dp"
android:elevation="2dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/addressImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="#+id/layoutAddress"
app:layout_constraintBottom_toBottomOf="#+id/layoutAddress"
app:layout_constraintStart_toStartOf="#+id/layoutAddress"
app:srcCompat="#drawable/ic_home_black_24dp"
android:paddingLeft="#dimen/spacing_normal"/>
<!-- Donor type layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutHomeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintLeft_toRightOf="#+id/addressImageView"
app:layout_constraintTop_toTopOf="#+id/layoutAddress"
android:layout_marginLeft="#dimen/spacing_normal">
<TextView
android:id="#+id/tvAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Demo"
android:textSize="#dimen/font_normal"
app:layout_constraintTop_toTopOf="#+id/layoutHomeView"
app:layout_constraintStart_toStartOf="#+id/layoutHomeView"/>
<TextView
android:id="#+id/tvAddressLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="#string/donor_address_hint"
android:textSize="#dimen/font_normal"
tools:text="sfsfgagaggsggddeggdgagahhahahahahhahahgsgjaaasshhs"
android:paddingRight="#dimen/spacing_xxhuge"
app:layout_constraintEnd_toEndOf="#+id/layoutHomeView"
app:layout_constraintTop_toBottomOf="#+id/tvAddress" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
And also adding screenshot.
Please look into this issue as I am struggling this issue long.
Your last material card constraint and width is wrong.
Also, You can remove more layout hierarchy like in Donor type layout you can remove unnecessary constraintlayout.
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/background_light"
android:padding="#dimen/spacing_large">
<com.google.android.material.card.MaterialCardView
android:id="#+id/groupCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/spacing_normal"
android:elevation="2dp"
app:cardElevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/groupImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/spacing_normal"
app:layout_constraintBottom_toBottomOf="#+id/layoutGroup"
app:layout_constraintStart_toStartOf="#+id/layoutGroup"
app:layout_constraintTop_toTopOf="#+id/layoutGroup"
app:srcCompat="#drawable/ic_launcher_background" />
<!-- Donor type layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutGroupView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/spacing_normal"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintStart_toEndOf="#+id/groupImageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="#+id/groupImageView"
app:layout_constraintTop_toTopOf="#+id/layoutGroup">
<TextView
android:id="#+id/tvGroupName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Demo"
android:textSize="#dimen/font_normal"
app:layout_constraintEnd_toEndOf="#+id/layoutGroupView"
app:layout_constraintStart_toStartOf="#+id/layoutGroupView"
app:layout_constraintTop_toTopOf="#+id/layoutGroupView" />
<TextView
android:id="#+id/tvGroupNameLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="group_label"
android:textSize="#dimen/font_normal"
app:layout_constraintEnd_toEndOf="#+id/layoutGroupView"
app:layout_constraintStart_toStartOf="#+id/layoutGroupView"
app:layout_constraintTop_toBottomOf="#+id/tvGroupName" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/mobileCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/spacing_large"
android:elevation="2dp"
app:cardElevation="2dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#+id/groupCardView">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/phoneImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/spacing_normal"
app:layout_constraintBottom_toBottomOf="#+id/layoutPhone"
app:layout_constraintStart_toStartOf="#+id/layoutPhone"
app:layout_constraintTop_toTopOf="#+id/layoutPhone"
app:srcCompat="#drawable/ic_launcher_background" />
<!-- Donor type layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutPhoneView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/spacing_normal"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintEnd_toEndOf="#+id/layoutPhone"
app:layout_constraintStart_toEndOf="#+id/phoneImageView"
app:layout_constraintTop_toTopOf="#+id/layoutPhone">
<TextView
android:id="#+id/tvPhone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal"
app:layout_constraintEnd_toEndOf="#+id/layoutPhoneView"
app:layout_constraintStart_toStartOf="#+id/layoutPhoneView"
app:layout_constraintTop_toTopOf="#+id/layoutPhoneView"
tools:text="Demo" />
<TextView
android:id="#+id/tvPhoneLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="phone_label"
android:textSize="#dimen/font_normal"
app:layout_constraintEnd_toEndOf="#+id/layoutPhoneView"
app:layout_constraintStart_toStartOf="#+id/layoutPhoneView"
app:layout_constraintTop_toBottomOf="#+id/tvPhone" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
android:id="#+id/addressCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/spacing_large"
android:elevation="2dp"
app:cardElevation="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/mobileCardView">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/addressImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/spacing_normal"
app:layout_constraintBottom_toBottomOf="#+id/layoutAddress"
app:layout_constraintStart_toStartOf="#+id/layoutAddress"
app:layout_constraintTop_toTopOf="#+id/layoutAddress"
app:srcCompat="#drawable/ic_launcher_background" />
<!-- Donor type layout -->
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/layoutHomeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/spacing_normal"
android:orientation="horizontal"
android:padding="10dp"
app:layout_constraintEnd_toEndOf="#+id/layoutAddress"
app:layout_constraintStart_toEndOf="#+id/addressImageView"
app:layout_constraintTop_toTopOf="#+id/layoutAddress">
<TextView
android:id="#+id/tvAddress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="#dimen/font_normal"
app:layout_constraintEnd_toEndOf="#+id/layoutHomeView"
app:layout_constraintStart_toStartOf="#+id/layoutHomeView"
app:layout_constraintTop_toTopOf="#+id/layoutHomeView"
tools:text="Demo" />
<TextView
android:id="#+id/tvAddressLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingRight="#dimen/spacing_xxhuge"
android:text="donor_address_hint"
app:layout_constraintEnd_toEndOf="#+id/layoutHomeView"
app:layout_constraintTop_toBottomOf="#+id/tvAddress"
tools:text="sfsfgagaggsggddeggdgagahhahahahahhahahgsgjaaasshhs" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
You have set width to 0dp. Instead use wrap_content:
android:id="#+id/tvAddressLabel"
android:layout_width="wrap_content" //here
android:layout_height="wrap_content"
Add app:layout_constraintEnd_toEndOf="parent”
To layoutHomeView and addressCardView
first: your text haven't whitespace and Android Studio thing is one word.
So in real world we haven't so longest word.
Just add whitespace.
Second: you created two containers for one cell. Example you create 1 container that include imageView and other container with textViews.
So you can use only 1 container that will include all views. Because your 'text container' go out of display (Added it on pictures).
I have the Button at the end of TextView:
When text is increasing, I get the following:
But I want that my button locates only at the end of text and doesn't move out of the screen when text is large:
This is my layout:
<LinearLayout
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:padding="10dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Long text without button"
android:textColor="#000"
android:textSize="36sp" />
<FrameLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content" >
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Button" />
</FrameLayout>
</LinearLayout>
If I move layout_weight from FrameLayout to AppCompatTextView then I get needed result, but with smal text I get the following:
I tried with LinearLayout weights and ConstraintLayout, but nothing to help me.
How to achieve this?
You just use ConstraintLayout.
Try this
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/text"
android:layout_width="0dp" <-- It means using match-constraint.
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Long text without button"
android:textColor="#000"
android:textSize="36sp"
app:layout_constraintEnd_toStartOf="#+id/button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Button"
app:layout_constraintBottom_toBottomOf="#id/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/text"
app:layout_constraintTop_toTopOf="#id/text" />
</androidx.constraintlayout.widget.ConstraintLayout>
Result
Additional XML - version wrap_content
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:maxLines="1"
android:text="short text"
android:textColor="#000"
android:textSize="36sp"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="#+id/button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="Button"
app:layout_constraintBottom_toBottomOf="#id/text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#id/text"
app:layout_constraintTop_toTopOf="#id/text" />
</androidx.constraintlayout.widget.ConstraintLayout>
Modify layout_constraintHorizontal_bias attributes of TextView to fit layout you want.
Try this method using Grid Layout and AppcompatTextview hope it helps you.
<LinearLayout
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:padding="10dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:rowCount="1">
<androidx.appcompat.widget.AppCompatTextView
android:id="#+id/text"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:ellipsize="end"
android:autoSizeTextType="uniform"
android:autoSizeMinTextSize="12sp"
android:autoSizeMaxTextSize="100sp"
android:autoSizeStepGranularity="2sp"
android:maxLines="1"
android:layout_columnWeight="0"
android:text="Long text without button"
android:textColor="#000"
android:textSize="20sp" />
<FrameLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_columnWeight="1">
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Button" />
</FrameLayout>
</GridLayout>
</LinearLayout>
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);