私はかなりシンプルですRecyclerView
の中にDialogFragment
1行の項目はイメージ、姓といくつかの数字を表示することになっています。レイアウトはlayout_weightの助けを借りてレイアウトされ、利用可能なスペースを均等に共有します。Android RecyclerViewがうまくレイアウトされていません
何らかの理由で、項目のいくつかがランダムにlayout_weightを間違って計算しているようです。
が問題のある項目をスクロールして表示された後、エディタのプレビューでになると、問題は解決され、レイアウトは正常に戻ります。
画像でわかるように、最初の項目(必ずしも最初の項目ではない)では、画像があまりにも多くのスペースを取得します。
次のように私のレイアウトです。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dodger_blue"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:id="@+id/iv_face"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:id="@+id/et_first_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLargeInverse"
android:textStyle="bold"/>
<TextView
android:id="@+id/et_surname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMediumInverse"/>
</LinearLayout>
<TextView
android:id="@+id/et_id"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMediumInverse"/>
<TextView
android:id="@+id/et_place"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:gravity="center|end"
android:textAppearance="?android:attr/textAppearanceLargeInverse"/>
</LinearLayout>
そして、私のアダプタ。 https://gist.github.com/StefanDeBruijn/f032eac6619ac1b8420e352b883ea4dd
'Adapter'の' inflate() 'コールで親の' ViewGroup'を渡していますか? –
はい、私の全体のアダプターを追加しました –