CymChad / CymChad/BaseRecyclerViewAdapterHelper

GridLayout 佈局中, 怎麼設定header 為一橫條

Open
#3,356 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
24.6k
Forks
5.2k
PR merge metrics
No merged PRs in 30d

Description

我依照這邊的只是施作想達到一樣的效果
https://github.com/CymChad/BaseRecyclerViewAdapterHelper/wiki/Add-group
預期
Screen Shot 2020-11-02 at 4 33 06 PM
但實際變成這樣

Screen Shot 2020-11-02 at 4 34 11 PM

我設定RecylerView是如下設置
...
viewBinding.recyclerView.setAdapter(adapter);
viewBinding.recyclerView.setHasFixedSize(true);
GridLayoutManager gridLayoutManager = new GridLayoutManager(viewBinding.getRoot().getContext(), 2);
viewBinding.recyclerView.setLayoutManager(gridLayoutManager);

...

header view xml

<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="56dp">

<ImageView
    android:id="@+id/imageView13"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:src="@mipmap/face_003"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"/>

<TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="8dp"
    android:text="誒羅喔誒羅"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toEndOf="@+id/imageView13"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/moreBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="16dp"
    android:text="MotoMoto >>"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the Add-group wiki example with the shown RecyclerView and GridLayoutManager setup. Review the header view XML and determine why the header does not occupy the full two-column row. Done means the header matches the expected full-width screenshot while the item grid remains two columns.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.