错误"找不到类android.graphics.drawable.RippleDrawable"更改FAB图标

时间:2017-08-15 08:42:55

标签: android xml floating-action-button bottomnavigationview rippledrawable

我有一个Fab,我正在使用它来隐藏或显示我的应用程序中的BottomNavigationBar。在andorid 7.0(1080p)中一切正常,但是当我尝试在android 4.4(720p)中运行应用程序时,FAB不可见。

此外,当我隐藏或显示bottomNavigationBar时,我将分别向下移动FAB并更改FAB上的图标,以使其看起来更好一些。

这是我的XML代码

<RelativeLayout android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom|end"
    android:clickable="true"
    app:fabSize="mini"
    app:elevation="8dp"
    app:rippleColor="@color/colorPrimary"
    android:layout_margin="16dp"
    app:srcCompat="@drawable/ic_show" />

<FrameLayout android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/container"
    xmlns:android="http://schemas.android.com/apk/res/android">

       <!-- frame layout content -->

</FrameLayout>

    <FrameLayout
        android:id="@+id/frame_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:elevation="3dp">

       <!-- frame layout content -->

    </FrameLayout>


        <android.support.design.widget.BottomNavigationView
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_alignParentBottom="true"
            android:background="@color/colorPrimary"
            android:iconifiedByDefault="false"
            app:itemIconTint="#fff"
            app:itemTextColor="#fff"
            app:menu="@menu/bottom_bar"/>

</RelativeLayout>

这是我在Activity

中的代码
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if(bottomNavigationView.getVisibility() == View.VISIBLE){

                bottomNavigationView.setVisibility(GONE);

                fab.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_show));

                final ObjectAnimator moveFab
                        = ObjectAnimator.ofFloat(fab, View.TRANSLATION_Y, fab.getY(), 0);
                moveFab.setDuration(300);
                moveFab.setInterpolator(new DecelerateInterpolator());
                moveFab.start();

            }else if(bottomNavigationView.getVisibility() == View.GONE){

                bottomNavigationView.setVisibility(View.VISIBLE);

                fab.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_hide));

                final ObjectAnimator moveFab
                        = ObjectAnimator.ofFloat(fab, View.TRANSLATION_Y, fab.getY(), -150);
                moveFab.setDuration(300);
                moveFab.setInterpolator(new DecelerateInterpolator());
                moveFab.start();

            }

        }
    });

我的日志猫说

Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

使用android 4.4不支持的东西,或者我只是犯了什么错误?

我已经经历了许多类似标题的问题,似乎没什么关系。

0 个答案:

没有答案
相关问题