android - FloatingActionButton 未在 API 16 上显示

标签 android floating-action-button

我在布局中使用FloatingActionButton:

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="61dp"
    android:clickable="true"
    app:fabSize="mini"
    android:src="@android:drawable/btn_star_big_off"
    android:id="@+id/floatingActionButton"
    app:layout_anchor="@+id/container"
    app:layout_anchorGravity="bottom|right"
    android:layout_gravity="start"
    android:layout_marginBottom="20dp"
    android:layout_marginEnd="20dp"
    android:layout_marginRight="20dp"
    app:backgroundTint="@color/colorAccent"
    />

创建Activity时,我在其中放入了一个图像:

favbtn = (FloatingActionButton) findViewById(R.id.floatingActionButton);
favbtn.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), btn_star_big_on));

在旧设备(例如 API 16)上进行测试时,按钮不显示/不可见。有办法解决这个问题吗?

最佳答案

用 favbtn.bringToFront() 修复了它

关于android - FloatingActionButton 未在 API 16 上显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42302947/

相关文章:

java - 无法获得 instagram 个人资料图片全尺寸

java - CreateView 方法上的自定义对话框在 firebase firestore onCompletelistener 获取数据到列表之前返回

android - float 操作按钮 : Setting a custom background is not supported

android - 我的 FloatingActionButton 显示在我的 TextView 和图像下方

java - 关于 Firestore 是否有一些标志我可以检查数据是否在线/离线数据?

java - 是否必须创建内部类来处理 DataBinding 中的事件?

java - 如何使用 jsoup post 请求提交没有按钮名称的表单

android - 当 snackbar 动画开始时, float Action 按钮会上下跳跃

android - 右侧的 float 操作按钮标签

android - 如何将 FAB 对齐到布局边框顶部