Issue: Character Counter Runs Off Screen
I am finding it extremely difficult to have a character counter which does not disappear once the input text scrolls over one screen size.
This is what I have in the layout xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:android.support.design="http://schemas.android.com/tools">
<android.support.design.widget.TextInputLayout
android:id="@+id/textContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
android:overScrollMode="never"
android.support.design:errorEnabled="true"
android.support.design:hintEnabled="true"
app:counterMaxLength="@integer/global_comments_size">
<android.support.design.widget.TextInputEditText
android:id="@+id/action_global_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_marginTop="8dp"
android:hint="@string/edit_comments"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:scrollbars="vertical"
android:maxLength="@integer/global_comments_size"
/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
counter visible until scroll leaves the screen
Counter becomes invisible as the text scroll over the screen
Probable Options:
I see following three options as possible solutions.
Make a bottom toolbar and add the counter programmatically
Make a pop-up show programmatically once the maximum size is reached
Somehow configure TextInputLayout in xml or use some other library.
I would prefer option 3. However, am at loss right now and do not find any solution or hint neither in the documentation nor by googling the forums.
Solved
Solution Found
After more reading I found out that the question has already been asked on stackoverflow here about counter running off the screen with solution proposals. However, the solution is not as expected with a simple xml entry but has to be done programmatically
I am posting my solution with source code based on the information collected from here and here.