FAB:pressedTranslationZ 不起作用
FAB: pressedTranslationZ does not work
我的浮动操作按钮在按下时没有升高。
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/white"
android:id="@+id/layout">
<android.support.v7.widget.RecyclerView
android:id="@+id/multiple_tally_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
app:backgroundTint="@android:color/holo_orange_dark"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:srcCompat="@drawable/ic_add_black_24dp" />
</RelativeLayout>
似乎app:pressedTranslationZ
没有正常工作。我该如何解决?
已解决。我只是在没有设置 OnClickListener
的情况下测试我的 FAB,最后我设置了 OnClickListener
然后它开始在点击时提升。
您可能错过了设置 OnClickListener
在 FAB 上,当 pressed.Simply 时,pressedTranslationZ 会导致阴影变大
setOnClickListener 如下所示:
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// implementation Code here
}
我的浮动操作按钮在按下时没有升高。
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@android:color/white"
android:id="@+id/layout">
<android.support.v7.widget.RecyclerView
android:id="@+id/multiple_tally_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
app:backgroundTint="@android:color/holo_orange_dark"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:srcCompat="@drawable/ic_add_black_24dp" />
</RelativeLayout>
似乎app:pressedTranslationZ
没有正常工作。我该如何解决?
已解决。我只是在没有设置 OnClickListener
的情况下测试我的 FAB,最后我设置了 OnClickListener
然后它开始在点击时提升。
您可能错过了设置 OnClickListener
在 FAB 上,当 pressed.Simply 时,pressedTranslationZ 会导致阴影变大 setOnClickListener 如下所示:
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// implementation Code here
}