Monday, 28 May 2018

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. 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.enter image description here

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



from Edit text scroll bar issue in Constraint layout

No comments:

Post a Comment