Skip to content

Commit e4a1fbb

Browse files
committed
+ demo
1 parent 9bf9ec9 commit e4a1fbb

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

Sample/src/main/java/com/angcyo/dsltablayout/demo/SlidingFragment.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,17 @@ class SlidingFragment : BaseTabLayoutFragment() {
235235
}
236236
}
237237
}
238-
// slidingItem {
239-
// itemBindOverride = { itemHolder, _, _, _ ->
240-
// itemHolder.v<DslTabLayout>(R.id.tab_layout)?.apply {
241-
// addTabLayout(this)
242-
// tabIndicator.indicatorWidth = 10 * dpi
243-
// tabIndicator.indicatorEnableFlow = true
244-
// tabIndicator.indicatorStyle = DslTabIndicator.INDICATOR_STYLE_BOTTOM
245-
//
246-
// setTabLayoutConfig {
247-
// tabEnableGradientScale = true
248-
// tabEnableGradientColor = true
249-
// tabSelectColor = resources.getColor(R.color.colorAccent)
250-
// }
251-
// }
252-
// }
253-
// }
238+
239+
//渐变指示器
240+
slidingItem {
241+
itemBindOverride = { itemHolder, _, _, _ ->
242+
itemHolder.v<DslTabLayout>(R.id.tab_layout)?.apply {
243+
addTabLayout(this)
244+
tabIndicator.indicatorStyle = DslTabIndicator.INDICATOR_STYLE_BOTTOM
245+
tabIndicator.indicatorDrawable = getDrawable(R.drawable.indicator_gradient)
246+
}
247+
}
248+
}
254249

255250
//角标配置
256251
slidingItem {
@@ -289,20 +284,24 @@ class SlidingFragment : BaseTabLayoutFragment() {
289284
tabBadge.badgeOffsetX = 10 * dpi
290285
tabBadge.badgeOffsetY = 4 * dpi
291286
}
287+
292288
2 -> {
293289
tabBadge.badgeGravity = Gravity.RIGHT or Gravity.TOP
294290
tabBadge.badgeText = "99"
295291
}
292+
296293
3 -> {
297294
tabBadge.badgeGravity = Gravity.RIGHT or Gravity.BOTTOM
298295
tabBadge.badgeText = "99+"
299296
tabBadge.gradientStrokeColor = Color.BLACK
300297
tabBadge.gradientStrokeWidth = 2 * dpi
301298
}
299+
302300
4 -> {
303301
tabBadge.badgeGravity = Gravity.LEFT or Gravity.BOTTOM
304302
tabBadge.badgeText = "999+"
305303
}
304+
306305
5 -> {
307306
tabBadge.badgeCircleOffsetX = 14 * dpi
308307
tabBadge.badgeCircleOffsetY = 6 * dpi
@@ -311,6 +310,7 @@ class SlidingFragment : BaseTabLayoutFragment() {
311310
tabBadge.gradientStrokeColor = Color.BLUE
312311
tabBadge.gradientStrokeWidth = 2 * dpi
313312
}
313+
314314
else -> {
315315
tabBadge.badgeGravity = Gravity.CENTER
316316
tabBadge.badgeText = ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item>
4+
<shape android:shape="rectangle">
5+
<gradient
6+
android:angle="180"
7+
android:endColor="#ffffffff"
8+
android:startColor="@color/colorAccent"
9+
android:type="linear"
10+
android:useLevel="true" />
11+
<corners
12+
android:bottomLeftRadius="63dp"
13+
android:bottomRightRadius="63dp"
14+
android:topLeftRadius="63dp"
15+
android:topRightRadius="63dp" />
16+
</shape>
17+
</item>
18+
</layer-list>

0 commit comments

Comments
 (0)