RecyclerViewのすべてのアイテムには、テキストの下にテキストの上にある空き領域よりも多くの空き領域があります。ここで私が何を意味するかである:ここでは Image 1 Image 2Android RecyclerViewの不思議なアイテムのサイズ
は、アイテムの私のXMLコードです:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" android:background="?attr/selectableItemBackground"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:id="@+id/textViewItem" />
</LinearLayout>
はなぜそれはそれを行うのですか?
kinda解決策:paddingBottomを削除し、paddingTopを10dpにする - 固定テキストサイズでのみ動作します。
テキストビューでテキストを更新する場所 –
リスト行のレイアウトに他の要素を追加したり、テキストサイズを
TextView
に変更したり、行の高さを固定値に変更したりするとすぐに、ソリューションが機能しません。私はそれを回避する方法を説明と以下の答えを投稿します。 –