Edit text scroll bar issue in Constraint layout

relative layout constraints
constraint layout guideline
chain constraint layout
when to use constraint layout
horizontal bias constraint layout
convert relative layout to constraint layout
google constraintlayout
constraint layout in android tutorials point

I am trying to show scroll bar in my edit text only when height of my edit text reach at the end of my layout height. That's working fine if i am entering/adding blank space but its causing problem when I my text reaches to end of my edit text width. Once my text reaches to end of my edit text width it start showing me scroll bar whereas it should show up when i reach to (height)end of screen.

Please advice how can i resolve this issue. Please find attached image and code for reference.

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

    <EditText
        android:id="@+id/editFeedback"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:bufferType="spannable"
        android:gravity="top"
        android:hint="Some text"
        android:inputType="textCapSentences|textMultiLine"
        android:minHeight="120dp"
        android:overScrollMode="ifContentScrolls"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:selectAllOnFocus="true"
        android:textIsSelectable="true"
        android:textSize="16sp"
        app:layout_constraintBottom_toTopOf="@+id/buttonSend"
        app:layout_constraintEnd_toEndOf="@id/guidelineEnd"
        app:layout_constraintHeight_default="wrap"
        app:layout_constraintStart_toStartOf="@id/guidelineStart"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        app:layout_constraintVertical_chainStyle="packed"
        tools:text="" />

    <Button
        android:id="@+id/buttonSend"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:text="Send"
        android:textAllCaps="false"
        app:layout_constraintBottom_toBottomOf="@+id/barrierEnd"
        app:layout_constraintEnd_toEndOf="@id/guidelineEnd"
        app:layout_constraintTop_toBottomOf="@+id/editFeedback" />

    <TextView
        android:id="@+id/Footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:layout_marginBottom="100dp"
        android:text="This is a footer"
        android:textSize="15sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelineStart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="8dp" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelineEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_end="8dp" />

    <android.support.constraint.Barrier
        android:id="@+id/barrierEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="top"
        app:constraint_referenced_ids="Footer" />

</android.support.constraint.ConstraintLayout>

This might help I have edited a few things in the code. I have removed the barrier and changed it with a horizontal guideline and set that guideline to 80% of the screen height and the footer object aligned to that horizontal guideline. Kindly look the code below I hope it solves your problem. If you have any doubt about how I set the constraints I'll be happy to help.

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

    <EditText
        android:id="@+id/editFeedback"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="60dp"
        android:bufferType="spannable"
        android:gravity="top"
        android:hint="Some text"
        android:inputType="textCapSentences|textMultiLine"
        android:minHeight="120dp"
        android:overScrollMode="ifContentScrolls"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:selectAllOnFocus="true"
        android:textIsSelectable="true"
        android:textSize="16sp"
        app:layout_constraintBottom_toTopOf="@+id/guideline"
        app:layout_constraintEnd_toEndOf="@id/guidelineEnd"
        app:layout_constraintHeight_default="wrap"
        app:layout_constraintStart_toStartOf="@id/guidelineStart"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        tools:text="" />

    <Button
        android:id="@+id/buttonSend"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:layout_gravity="end"
        android:layout_marginBottom="8dp"
        android:layout_marginTop="8dp"
        android:text="Send"
        android:textAllCaps="false"
        app:layout_constraintBottom_toTopOf="@+id/guideline"
        app:layout_constraintEnd_toEndOf="@id/guidelineEnd"
        app:layout_constraintTop_toBottomOf="@+id/editFeedback"
        app:layout_constraintVertical_bias="0.00999999" />

    <TextView
        android:id="@+id/Footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:layout_marginBottom="8dp"
        android:text="This is a footer"
        android:textSize="15sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@+id/guideline" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelineStart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="8dp" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelineEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_end="8dp" />

    <android.support.constraint.Guideline
        android:id="@+id/guideline"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.8" />

</android.support.constraint.ConstraintLayout>

And also here is the image of how now the layout looks.

Constraint layout not scrolling, Google had introduced android constraint layout editor at Google I/O that Edit text scroll bar issue in Constraint layout I am trying to show scroll bar in my edit  Edit text scroll bar issue in Constraint layout I am trying to show scroll bar in my edit text only when height of my edit text reach at the end of my layout height. That's working fine if i am entering/adding blank space but its causing problem when I my text reaches to end of my edit text width.

Its work my side Please check at your side may be its.

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

    <EditText
        android:id="@+id/editFeedback"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:bufferType="spannable"
        android:gravity="top"
        android:hint="Some text"
        android:inputType="textCapSentences|textMultiLine"
        android:minHeight="120dp"
        android:overScrollMode="ifContentScrolls"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:selectAllOnFocus="true"
        android:textIsSelectable="true"
        android:textSize="16sp"
        app:layout_constraintBottom_toTopOf="@+id/buttonSend"
        app:layout_constraintEnd_toEndOf="@+id/guidelineEnd"
        app:layout_constraintHeight_default="wrap"
        app:layout_constraintStart_toStartOf="@+id/guidelineStart"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.0"
        app:layout_constraintVertical_chainStyle="packed"
        tools:text="" />

    <Button
        android:id="@+id/buttonSend"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:text="Send"
        android:textAllCaps="false"
        app:layout_constraintBottom_toBottomOf="@+id/barrierEnd"
        app:layout_constraintEnd_toEndOf="@+id/guidelineEnd"
        app:layout_constraintTop_toBottomOf="@+id/editFeedback" />

    <TextView
        android:id="@+id/Footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:layout_marginBottom="100dp"
        android:text="This is a footer"
        android:textSize="15sp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelineStart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_begin="8dp" />

    <android.support.constraint.Guideline
        android:id="@+id/guidelineEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_end="8dp" />

    <android.support.constraint.Barrier
        android:id="@+id/barrierEnd"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:barrierDirection="top"
        app:constraint_referenced_ids="Footer" />

</android.support.constraint.ConstraintLayout>

Linear Layout, All children of a LinearLayout are stacked one after the other, so a vertical list will only have one child per row, no matter how wide they are, and a  There is a bug in version 2.2 that makes it impossible to scroll the ConstraintLayout. I guess it still exists. You can use LinearLayout or RelativeLayout alternatively. Also, check out: Is it possible to put a constraint layout inside a ScrollView.

I believe it could be achieve programatically.

Disabling the vertical scroll bar when text reaches the last character of the line will do the trick. editText.setVerticalScrollBarEnabled(false);. Also, after the text is back at the next line, the scroll bar can be set again to true editText.setVerticalScrollBarEnabled(true);

I good start could be implementing interfaces like TextWatcher and EditText.OnScrollChangeListener and using them both while enabling/disabling scrollbar.

EditText, When you define an edit text widget, you must specify the android.R.styleable#​TextView_inputType attribute. For example, for plain text input set inputType to  Click the Preview tab on the right side of the layout editor to see a preview of the layout. The layout now looks like the right side of the following figure: 2.3 Run the app. To examine how the text scrolls: Run the app on a device or emulator. Swipe up and down to scroll the article. The scroll bar appears in the right margin as you scroll.

The problem here is windowSoftInputMode . If you do not specify windowSoftInputMode in manifest then it will be default as stateUnspecified or adjustUnspecified.

Right now your EditText is being resize when softkeyboard opens . Try to add a windowSoftInputMode to avoid resizing or put the layout in ScrollView(In case if you want whole layout to be visible during soft keyboard open).

you can specify adjustNothing flag. It will prevent the resize.

<activity android:name=".MainActivity"
        android:windowSoftInputMode="adjustNothing"
        >
    </activity>

Constraint layout inside scrollview not scrolling, XML File: in my project when i put constraint layout in scrollview not scroll and 2010 Edit text scroll bar issue in Constraint layout I am trying to show scroll bar  Edit text scroll bar issue in Constraint layout; Get duration of remote MP3 file without full downl Android Animating Constraint Layouts; Month name is appearing with M+number in datePicke Replicate the WhatsApp swipe between tabs transiti Android buttons are only clickable on the corners; Use an IIFE approach and pass a variable from

Recyclerview not scrolling in constraint layout, Edit text scroll bar issue in Constraint layout. I am trying to show scroll bar in my edit text only when height of my edit text reach at the end of my layout height. Constraint Layout Tutorial With Example In Android Studio [Step by Step] Constraint Layout is a ViewGroup (i.e. a view that holds other views) which allows you to create large and complex layouts with a flat view hierarchy, and also allows you to position and size widgets in a very flexible way.

What does Android isScrollContainer do? (ScrollView, TextView , Scrolling is working but it's not working smoothly when I scroll over the Edit text scroll bar issue in Constraint layout I am trying to show scroll bar in my edit text  Well the prime concern for the developer is layout selection whether to go with Relative, Linear, Frame or Percentage Relative layout and in case of any change in the UI thereafter will add up an extra overhead and sometime in worst case scenario it may leads to recreating the entire layout. To avoid such problem android is having a perfect

Just place ConstraintLayout inside ScrollView, Set this if the view will serve as a scrolling container, meaning that it can be If not set, the default value will be true if “scrollbars” has the vertical scrollbar set, else it will be false. As a more complete example, I just created an Android EditText component like this: android:layout_height="wrap_content"  “Just place ConstraintLayout inside ScrollView” is published by Piotr Krystyniak. How can i implement scroll viewer in Constraint Layout ? 12. 1. Char Waka. Piotr Krystyniak. Follow. Sep

Comments
  • Please state what version of ConstraintLayout you’re using.
  • As far as I know, there is no way to do this with the standard EditText. You say you want vertical bars, but only when the edit text is reaches "X" size, so you will have to measure your Edit Text and only enable the scrollbars programmatically when you reach certain threshold.
  • When you say "it's showing the scrollbar when text reaches width of EditText" you are assuming that this is not the first line of your EditText but your last line correct? Meaning, EditText' text is at last line as far as height?
  • @Martin Marconcini we are using constrain layout version 1.1.0 in our project.can share your code.
  • @RedM yes i know but i need the edit text to show scroll bar when it reaches to the bottom it can show show the scroll bar and weird thing is that i can't select any text from the EditText.
  • When I tried it, scrollbars appear only when the height of edit Text is just above the footer. And also can you show an elaborated picture of the problem like for eg. with the text that you actually like to be shown in that particular way. It would be very helpful
  • yes it will work perfectly when you hit enter for new line but on normal typing without hitting enter it will show the scroll bar after the minimum editText height is reached
  • @Jinu that is the nature of the EditText, if you need a custom behavior, you’ll have to write your own/extend/delegate as much as you can.
  • @MartinMarconcini it's working perfectly on other layouts so i have raised a bug for this issuetracker.google.com/issues/80393448