1

Hello stackoverflowers!Android Button Alpha在2.2和更低版本上看起來很奇怪

這是我的按鈕:

<Button 
android:layout_width="fill_parent" 
android:layout_height="0dp" 
android:layout_weight="0.30" 
android:text="@string/menu_button_newgame" 
android:id="@+id/button_newgame" 
/> 

當我設置它的阿爾法150

button_newgame.getBackground().setAlpha(150); 

它會在2.2看着奇怪!在2.3.3按鈕看起來正常。

的Android 2.3.3(正常)

enter image description here

的Android 2.2(越野車)

enter image description here

怎麼辦? :)

+0

你試過啓用抖動嗎? 'button_newgame.getBackground()。setDither(true)' – 2012-02-23 15:13:12

+0

使抖動不起作用 – tialawllol 2012-02-24 06:28:09

回答

1

這似乎是九個補丁的問題。

嘗試使用

android:layout_height="wrap_content" 

所有的按鈕具有相同的內容,他們應該保持相同的高度。

或者嘗試創建一個自定義九補丁drawable用作背景。

+0

這沒有把戲。 – tialawllol 2012-02-24 06:38:01

+0

看起來像Android 2.2和更低的水平切割按鈕,並將每個部分移動到一起。由於這兩部分的alpha值都是150,因此Android似乎試圖「結合」那些重疊的alpha。爲了解決這個問題,我改變了一下設計。 – tialawllol 2012-02-24 06:41:29

相關問題