Skip to content

Instantly share code, notes, and snippets.

View xckevin's full-sized avatar

kevin.liu xckevin

  • Alibaba Group
  • Hangzhou China
View GitHub Profile
xckevin / TextFlowLayout.kt
Last active March 3, 2023 07:37
支持View跟随Text的布局组件。如果TextView最后一行足够放下,则跟随TextView最后一行;放不下则换行。支持margin padding调整跟随位置。
class TextFlowLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ViewGroup(context, attrs, defStyleAttr) {
private lateinit var baseTextView: TextView
fun attachTextView(tv: TextView) {
xckevin / RecyclerViewSticky.kt
Created February 3, 2023 03:38
import android.util.Log
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
import androidx.recyclerview.widget.StaggeredGridLayoutManager
* Copyright (C) 2014 Square, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software