21
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RecyclerViewのItemDecorationでStickyHeaderをつくってみた

Last updated at Posted at 2017-02-24

ItemDecorationサイッキョ

普通はどうやって実現するのか知りませんが、去年のDroidKaigiでItemDecorationで実現できるよ!と外国の方が言っていたので、ItemDecorationでやってみました!

サンプル

sample.gif

課題

LayoutManagerの制限

LinearLayoutかつverticalかつreversedでない状態でしか動作確認してないです。

onDrawOverの描画がスクロールバーよりあとになる

onDrawOver()RecyclerView.draw()内で呼び出されますが、super.draw()よりもあとの描画になります。
super.draw()ではスクロールバーの描画処理が行われており、そのあとのdrawは必然的にスクロールバーの上に描画されてしまいます。

これを実装で解決しようとするとものすごい労力がかかる(onDraw()onDrawOver()を使い分けたり?)ので、 onDrawOver()のコールタイミング修正してくれないかなーって感じです。

21
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
18

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?