ConstraintLayout通知徽章

时间:2017-04-16 05:37:29

标签: android android-layout android-constraintlayout

关于ConstraintLayout通知徽章

我已使用ConstraintLayout进行通知,如下所示。

这里我使用了ImageButton和textview   enter image description here

out put:

enter image description here

这里我使用了Button和textview

enter image description here

输出:

enter image description here

使用了imageview的按钮然后看起来像这样。 可以帮助我在constraintLayout中解决这个问题。

ex:enter image description here

当我尝试使用按钮时,它显示如下。

如果您正在使用FrameLayout或RelativeLayout显示徽章,我必须知道的另一件新事物适用于Button,ImageView或ImageButtom。

但是长按或点击按钮通知徽章后退,在Imageview和图像按钮中它工作正常。

3 个答案:

答案 0 :(得分:3)

这种情况发生了,因为Button有自己的高程。

更高的海拔,可以看到前方的景色。

尝试在徽章中添加更高的高程,如下所示。

android:elevation="10dp"

而且,您不想缩放图像,必须使用ImageView或ImageButton。

答案 1 :(得分:2)

在Button xml

中使用此style="?android:attr/borderlessButtonStyle"
<Button
        style="?android:attr/borderlessButtonStyle"
        android:background="@mipmap/ic_launcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

答案 2 :(得分:0)

最终我得到了上述问题的解决方案

1:用于按钮     android:elevation不会影响beacuse内部它有高程。

instead of elevation use android:stateListAnimator="@null"

2:对于其他按钮高程将起作用

相关问题