android滑动 ui渐变,AndroidGradientUI

1. Include library

Using AndroidStudio

Edit your build.gradle file and add below dependency:

dependencies {

compile 'com.david.gradientuilib:gradientuilibrary:1.0.1'

}

2. Using in layout.xml

GradientIconView

First the custom attribute should declare in xml like this:

xmlns:app="http://schemas.android.com/apk/res-auto"

Then you can add GradientIconView in layout.xml

android:id="@+id/id_iconfont_chat"

app:bottom_icon="@mipmap/chats"

app:top_icon="@mipmap/chats_green"

android:layout_width="40dp"

android:layout_height="35dp" />

The GradientIconView can gradient change itself from top_icon to bottom_icon.

GradientIconView will show top icon completely like this:

gradientIconView.setIconAlpha(1.0f);

And it will show bottom icon completely like this:

gradientIconView.setIconAlpha(0);

GradientTextView

You can add GradientTextView in layout.xml like this.

android:id="@+id/id_chats_tv"

app:bottom_text_color="@color/tab_text_gray"

app:text="@string/chats"

app:text_size="12sp"

app:top_text_color="@color/tab_bg_green"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

The GradientTextView can gradient change itself textcolor from top_text_color to bottom_text_color.

GradientIconView will show top textcolor completely like this:

gradientTextView.setTextViewAlpha(1.0f);

And it will show bottom textcolor completely like this:

gradientTextView.setTextViewAlpha(0);

3. Running effect

wechatsample.gif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值