Android L移动募集普通按钮 [英] Android L Raised Normal Button
本文介绍了Android L移动募集普通按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直没有使用的背景和一个自定义视图完全做自己捕猎高和低的方式来获得一个调高圆角矩形按钮。我想这样的按钮:
I've been hunting high and low for a way to get a "raised" rounded rectangular button without completely doing it myself using backgrounds and a custom view. I want buttons like this:
我认为这将做到这一点:
I thought this would do it:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter the Danger Zone"
android:id="@+id/btn"
android:elevation="8dp" <!-- Here -->
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"/>
</RelativeLayout>
但是,这什么也不做。该按钮看起来是一样的。 WTF?
But this does nothing. The button looks the same. WTF?
是的,我使用的是最新的SDK,等等等等。
And yes, I'm using the latest SDK, etc. etc.
编辑:
所以我增加了一个translationZ。现在,一个影子显示为活动正在打开,但是当动画完成消失。 ???
So I added a translationZ. Now, a shadow appears as the activity is opening, but disappears when the animation is done. ???
推荐答案
尝试添加状态列表动画师:
Try adding state list animator:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="true"
android:state_pressed="true">
<set>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="8dp"
android:valueType="floatType" />
</set>
</item>
<item>
<set>
<objectAnimator
android:duration="@android:integer/config_shortAnimTime"
android:propertyName="translationZ"
android:valueTo="2dp"
android:valueType="floatType" />
</set>
</item>
</selector>
这篇关于Android L移动募集普通按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文