2016-08-03 29 views
-1

如何在Android中的背景圖片上添加按鈕?Make buttons working

我已經添加了背景,現在我想添加一個按鈕並使其在後臺工作。我試圖添加多個按鈕,但他們都不工作,我不知道如果它的佈局或其他東西。

這是我到目前爲止有:

<Button 
    style="?android:attr/buttonStyleSmall" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="back" 
    android:id="@+id/button2" 
    android:layout_alignTop="@+id/button" 
    android:background="@drawable/scan1" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentStart="false" 
    android:layout_alignParentLeft="false" /> 

我編輯的代碼,所以「SCAN1」繪製的是顯示紅色。

+3

請花一看。 http://stackoverflow.com/questions/4954102/button-background-as-transparent – humazed

+0

你給它一個背景圖片,你如何期待它是透明的? –

+0

穆罕默德,我得到這個圖像,有應用程序按鈕應該去的地方,我做了這個我的背景圖像。現在我想把這些按鈕放在那些地方,然後讓它們變得透明,這樣它們就與背景融合在一起,我不知道你是否理解我。 –

回答

0

透明按鈕

android:background="@null" 

android:background="@android:color/transparent" 
0

使用FancyButtons庫創建具有透明背景的按鈕。設置fb_defaultColor PARAM如下:

fancy:fb_defaultColor="@android:color/transparent" 

使用這個庫,你不會失去按鈕點擊連鎖反應。

0
android:background="?android:attr/selectableItemBackground" 

添加到您的按鈕xml ..希望這有助於

0

您還可以使用:在你的XML:

android:background="@null" 

或代碼:

button.setBackgroundColor(Color.TRANSPARENT);