admin管理员组文章数量:1573363
Touch Feedback(触摸反馈)
例子:水波纹效果
水波纹效果是5.0+自带的。
<Button
android:layout_width="wrap_content"
android:layout_height="100dp"
android:text="hello_world" />
<Button
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="?attr/selectableItemBackground"
android:text="hello_world" />
<Button
android:layout_width="wrap_content"
android:layout_height="100dp"
android:background="?attr/selectableItemBackgroundBorderless"//没有边界,圆形
android:text="hello_world" />
Button背景颜色设置不同的背景。
android:background=”?attr/selectableItemBackground”
android:background=”?attr/selectableItemBackgroundBorderless”//没有边界,圆形
可以修改背景颜色和水波纹的颜色:
value-v21/styles.xml
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorControlHighlight">@color/colorPrimary_pink</item>
<item name="colorButtonNormal">@color/material_blue_grey_800</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
Activity或者Application的android:theme="@style/AppTheme"
这样就可以改变5.0以上水波纹的颜色
最好使用AppcompatActivity
Reveal Effect(揭露效果)
例子:Activity的揭露出现的效果。
ViewAnimationUtil工具类
//圆形水波纹揭露效果
ViewAnimationUtils.createCircularReveal(
view, //作用在哪个View上面
centerX, centerY, //扩散的中心点
startRadius, //开始扩散初始半径
endRadius)//扩散结束半径
// 中心扩散的揭露效果
final Animator circularReveal = ViewAnimationUtils.createCircularReveal(bt1, bt1.getWidth() / 2, bt1.getHeight() / 2, 0, bt1.getHeight());
circularReveal.setDuration(500);
circularReveal.setInterpolator(new AccelerateInterpolator());
circularReveal.start();
// 从左上角开始的揭露效果
Animator animator = ViewAnimationUtils.createCircularReveal(bt2, 0, 0, 0, (float)Math.hypot(bt2.getWidth(), bt2.getHeight()));
animator.setDuration(1000);
animator.setInterpolator(new AccelerateInterpolator());
animator.start();
本文标签: 反馈效果MaterialDesign
版权声明:本文标题:MaterialDesign的触摸反馈和揭露效果 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1727747347a1127963.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论