A simple customised version of the TextInputLayout from the Android Design Support Library ⌨️
(Coming to maven central soon!)
This is a simple customisation of the TextInputLayout found in the Design Support Library.
Whilst this is an awesome component that we've made great use of, we wanted to be able to display the counter so that the value displayed was:
Hence why we created this simple component :)
In exactly the same way as the support library! Simply wrap an edit text field like so:
<org.buffer.android.buffertextinputlayout.BufferTextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="10"
app:counterOverflowTextAppearance="@style/counterOverride"
app:counterTextAppearance="@style/counterText"
app:hintEnabled="true"
app:counterMode="ascending">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/text_hint" />
</org.buffer.android.buffertextinputlayout.BufferTextInputLayout>
In our XML layout, we can set two extra attributes for the BufferTextInputLayout:
e.g
app:displayFromCount="5"
app:counterMode="descending"
e.g.
bufferTextInputLayout.setCounterMode(CounterMode.DESCENDING);
bufferTextInputLayout.setCharactersRemainingUntilCounterDisplay(40);