我是新來的Android平臺,我正在開發一個應用程序,主要活動 正在使用對話框主題。我的漸變不顯示在我的Android項目中
我的UI設置非常符合我的需要,但漸變似乎不適合我。 我試過一個漸變標題欄,視圖,佈局,textView等,並在每種情況下梯度不顯示。 (到目前爲止,我只在模擬器上測試過它)。
我繪製的XML看起來是這樣的:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#00000000"
android:centerColor="#FFFFFFFF"
android:endColor="#00000000"
android:angle="90" />
</shape>
我用下面的設置背景幾個元素,但它永遠不會顯示出來:
android:background="@drawable/gradient_bg"
我已經嘗試不同的顏色和角度等等,但無濟於事。
如果我做了以下工作,但我更喜歡在XML中做到這一點。
GradientDrawable grad = new GradientDrawable(
Orientation.TOP_BOTTOM,
new int[] {Color.RED, Color.YELLOW}
);
this.getWindow().setBackgroundDrawable(grad);
任何人都可以幫忙嗎? 謝謝。