2017-04-16 105 views
7

關於ConstraintLayout通知標誌ConstraintLayout通知標誌

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

這裏我用的ImageButton和TextView的 enter image description here

出來放:

enter image description here

這裏我使用按鈕和TextView的

enter image description here

輸出:

enter image description here

insign of imageview is used by button it then it like this。 可以幫助我在constraintLayout中解決這個問題。

例如:enter image description here

當我tryed與按鈕,它顯示是這樣的。

如果您使用FrameLayout或RelativeLayout顯示徽章對Button,ImageView或ImageButtom都正常工作,我會知道一件新事物。

但長按或點擊按鈕通知徽章是返回,在Imageview和imagebutton它工作正常。

+0

你能嘗試添加機器人:海拔=「0dp」爲您的按鈕 –

+0

我想如果海拔=「10dp」陰影顯示 –

+0

我它不工作意思是使用0dp海拔按鈕,不使用任何徽章 –

回答

2

發生這種情況,因爲Button有自己的高程。

海拔較高,可以看到前方。

嘗試向下面的徽章添加更高的高程。

android:elevation="10dp" 

而且,您不想縮放圖像,必須使用ImageView或ImageButton。

+0

它不需要,如果我使用ImaeView或ImageButton,但我需要使用button.if我使用海拔它顯示陰影。 –

+0

@RKiranKumar你爲什麼需要使用按鈕?而android:elevation =「10dp」確實解決了你的問題? –

+0

我想試試按鈕 –

2

在按鈕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"/> 
+0

無邊框按鈕與基本按鈕類似,不同之處在於它們沒有邊框或背景,但在不同狀態期間仍會改變外觀,例如點擊時。 – CodeCameo

+0

如果它爲你工作,你可以接受答案將來的參考。 – CodeCameo

+0

對不起,這是行不通的,如果我在背景中應用風格消失,這是不正確的。 –

0

最終我得到了上述問題

1解決方案:爲按鈕 的android:海拔不會怎麼一回事,因爲內部效果有提升。

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

2:其它按鈕,然後擡高將工作