2015-11-12 34 views
1

我剛剛注意到Button和ImageButton的邊框看起來不一樣。 ImageButton完全平坦。我無法解釋它,我想將ImageButton作爲默認按鈕「3d-ish」。任何想法都歡迎!Button和ImageButton的外觀差異

這是我的XML代碼

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center"> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Power" 
     android:id="@+id/button1" 
     android:layout_gravity="center" 
     android:layout_weight="0" 
     android:layout_centerInParent="true" /> 

    <ImageButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/f_light_on" 
     android:id="@+id/button4" 
     android:layout_gravity="center" 
     android:layout_weight="0" 
     android:layout_centerInParent="true" /> 
</LinearLayout> 

,這是它的樣子對我棒棒糖平板電腦:提前 enter image description here

謝謝! 托馬斯

+0

你想要帶邊框的ImageButton? –

+0

你有沒有嘗試添加'風格:機器人:ATTR/buttonStyle' –

+0

它最好在新建文件夾繪製風格,並設置機器人:背景=「@繪製/ your_xml」,以保持一致 – Actiwitty

回答

2

Button有默認的提升(事實上,它有一個StateListAnimator提供當啓用按鈕海拔)下的材料主題,而ImageButton沒有。

+0

謝謝!此澄清的行爲,但似乎一致的不。 –

+0

'ImageButton'是經常與空背景一起使用,它不適用於設置高程。我們選擇在設計材質控件樣式時儘可能少地打破應用程序。 – alanv

相關問題