我已经在网上搜索了一个星期左右,以获得有关如何制作彩色凸起按钮但没有运气的示例或教程。
我希望在我的应用程序中实现以下内容,以获得更好的用户界面体验。
我确实遇到过卡片视图,但是当您编写一个包含很多按钮的大型程序时,由于该卡片视图,xml代码将变得更大。
因此,如果有以下任何快速简便的解决方案,请告诉我。
谢谢
更新
Normal button
and with color
我想您实际上是想在按钮上加高。不要使用卡,因为它需要更多资源。用于棒棒糖设备
<Button
...
android:stateListAnimator="@anim/my_animator" />
并在资源的anim文件夹中创建my_animator.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:state_enabled="true">
<set>
<objectAnimator android:propertyName="translationZ"
android:duration="@integer/button_pressed_animation_duration"
android:valueTo="@dimen/button_pressed_z_material"
android:valueType="floatType"/>
<objectAnimator android:propertyName="elevation"
android:duration="0"
android:valueTo="@dimen/button_elevation_material"
android:valueType="floatType"/>
</set>
</item>
<!-- base state -->
<item android:state_enabled="true">
<set>
<objectAnimator android:propertyName="translationZ"
android:duration="@integer/button_pressed_animation_duration"
android:valueTo="0"
android:startDelay="@integer/button_pressed_animation_delay"
android:valueType="floatType"/>
<objectAnimator android:propertyName="elevation"
android:duration="0"
android:valueTo="@dimen/button_elevation_material"
android:valueType="floatType" />
</set>
</item>
...
</selector>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句