2013-07-11 19 views
0

enter image description here如何刪除alocated文本drawableTop

<Button 
     android:id="@+id/profile" 
     style="@style/DashboardButton" 
     android:drawableTop="@drawable/abarprofile"/> 



<style name="DashboardButton"> 
     <item name="android:layout_gravity">center_vertical</item> 
     <item name="android:gravity">center_horizontal</item> 
     <item name="android:layout_width">wrap_content</item> 
     <item name="android:layout_height">wrap_content</item> 
     <item name="android:paddingLeft">10dp</item> 
     <item name="android:paddingRight">10dp</item> 
     <item name="android:background">@null</item> 
    </style> 

按鈕的空間是存在的,我需要那些空間的方式讓我的圖標包的內容?取出下面的空間文本無視空間上的左,右對於彼此之間的圖標空間,但我不需要下面和上面的圖像空間我怎麼能把它out.i能夠拿出上面的空間,但我不能拿出下面的空間,我怎麼能做到這一點?

回答

2

是的,你可以在按鍵的底部使用按鈕的完美高度像 的Android刪除空格:layout_height = 「40dip」

Lyaout代碼

<Button 
android:id="@+id/tvQuickContactCall" 
android:layout_width="wrap_content" 
android:layout_height="40dip" 
android:layout_marginRight="15dip" 
android:background="@android:color/transparent" 
android:drawableTop="@drawable/ic_call" 
android:layout_weight="1" 
/> 

圖形佈局

enter image description here

+0

一個問題隊友對@null使用透明背景顏色有什麼區別? – Giant

+0

是的透明有一個差異存在一個阿爾法層,所以我們可以增加和減少透明度,但如果我們把@null它意味着沒有層沒有。 – DynamicMind

+0

但在我的回答中,應該不會影響你的問題,你可以根據需要設置@null或transparent的背景。 – DynamicMind

0

如果你想要一個只有conta的按鈕INS的圖像(沒有文本),你應該使用一個ImageButton

<ImageButton 
    android:id="@+id/profile" 
    style="@style/DashboardButton" 
    android:src="@drawable/abarprofile"/> 
+0

我試過這一個,但我不能使用我的選擇器,因爲即時通訊使用按鈕選擇器來使我的按鈕狀態工作,但無論如何感謝第一個工作正常 – Giant

+0

@SatineKainne - 「ImageButtons」按鈕選擇器需要在'背景'而不是'src'屬性。 – ianhanniballake

0

你也可以嘗試使用裕如

<Button 
    android:id="@+id/btnButton" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="-10dip" 
    android:layout_marginRight="-10dip" 
    android:layout_marginTop="-10dip" 
    android:layout_marginLeft="-10dip" 
/> 

通過這樣做,負號實際刪除空格按鈕。