GradualRadioBar
拿RadioGroup和RadioButton开刀,实现微信底部导航栏图标颜色渐变效果
源码地址
https://github.com/leibnik/GradualRadioBar
效果
使用
gradle
compile 'io.github.leibnik:gradualradiobar:1.0.2'
xml
GradualRadioGroup和GradualRadioButton必须配合使用
<io.github.leibnik.gradualradiobar.GradualRadioGroup
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<io.github.leibnik.gradualradiobar.GradualRadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:drawablePadding="3dp"
android:drawableTop="@mipmap/home"
android:gravity="center_horizontal"
android:paddingBottom="5dp"
android:paddingTop="3dp"
android:text="AAA"
android:textColor="#555"
app:gradual_color="#f75151"/>
<io.github.leibnik.gradualradiobar.GradualRadioButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawablePadding="3dp"
android:gravity="center_horizontal"
android:paddingBottom="5dp"
android:paddingTop="3dp"
android:text="BBB"
android:textColor="#555"
app:gradual_icon="@mipmap/order"
app:gradual_color="#f75151"/>
</io.github.leibnik.gradualradiobar.GradualRadioGroup>
-
app:gradual_color
:渐变的颜色 -
app:gradual_icon
或者android:drawableTop
:设置图标
Java
gradualRadioGroup = (GradualRadioGroup) findViewById(R.id.radiobar);
viewPager.setAdapter(adapter);
// 关键代码
gradualRadioGroup.setViewPager(viewPager);
网友评论