diff --git a/simplerecyclerview/src/main/java/com/dino/library/dinorecyclerview/RecyclerViewExt.kt b/simplerecyclerview/src/main/java/com/dino/library/dinorecyclerview/RecyclerViewExt.kt index f00342e..df9aa6d 100755 --- a/simplerecyclerview/src/main/java/com/dino/library/dinorecyclerview/RecyclerViewExt.kt +++ b/simplerecyclerview/src/main/java/com/dino/library/dinorecyclerview/RecyclerViewExt.kt @@ -65,4 +65,19 @@ fun RecyclerView.setItemSpace(space: Float) { } val spacePixel = context.resources.displayMetrics.density * space addItemDecoration(DinoSpaceItemDecoration(spacePixel.toInt())) +} + +@BindingAdapter("dino_itemSpace") +fun RecyclerView.setItemSpace(space: String) { + if (!space.contains("dp")) { + return + } + val dpSpace = try { + space.dropLast(2).toFloat() + } catch (e: Exception) { + e.printStackTrace() + 0f + } + val spacePixel = context.resources.displayMetrics.density * dpSpace + setItemSpace(spacePixel) } \ No newline at end of file