Reputation: 1973
I placed a TextView below an EditText to display the latter's character count. This is how it looks like when the EditText is not in focus.
When the EditText is in focus:
As you can see, "7/500" has been covered by the TextView.
The XML for my activity:
<ScrollView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="20dp"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<ImageView
android:id="@+id/display_photo"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
<android.support.design.widget.TextInputLayout
android:id="@+id/caption_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp">
<android.support.design.widget.TextInputEditText
android:id="@+id/et_start_photo_story_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:gravity="bottom"
android:maxLength="500"
android:paddingBottom="15dp"
android:privateImeOptions="nm"
android:textColor="@color/black" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/tv_character_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:textColor="@color/grey700"
android:textSize="14sp" />
</LinearLayout>
</ScrollView>
I have this line inside my manifest android:windowSoftInputMode="adjustPan"
. I have tried changing the height of the ImageView, but the character count remains hidden when the EditText is in focus.
Upvotes: 3
Views: 2193
Reputation: 31
In case you are using dependency injection framework like com.google.dagger:hilt-android
place the android:windowSoftInputMode="adjustPan|adjustResize"
in the application section of the manifest instead of the activity section.
Upvotes: 0
Reputation: 589
Instead of setting as
android:windowSoftInputMode="adjustPan"
try setting as
android:windowSoftInputMode="adjustResize"
which will make your view scrollable when edittext is focused.
Upvotes: 2