2010-09-29 14 views
56

Tôi có gradient sau:Làm thế nào để tạo gradient trong suốt?

<?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android"> 
     <gradient 
      android:startColor="#ECECEC" 
      android:centerColor="#F6F6F4" 
      android:endColor="#F8F8F6" 
      android:angle="90" 
      android:dither="true" 
     /> 
    </shape> 

Tôi muốn điều này được minh bạch vì trong ListView của tôi, tôi đang thiết lập này như ListSelector tôi:

<ListView android:layout_width="fill_parent" 
       android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/ARListView" 
       android:background="@drawable/transparent_background" 
       android:cacheColorHint="#00000000" android:drawSelectorOnTop="true" 
       android:listSelector="@drawable/stocks_selected_gradient"> 
</ListView> 

Trả lời

108

Chỉ cần sử dụng một giá trị màu 8 chữ số, ví dụ # FFF8F8F6, trong đó hai ký tự đầu tiên là giá trị alpha. FF hoàn toàn mờ đục, và 00 hoàn toàn trong suốt.

+0

đen sang màu xám như thế nào? – Mikey

+1

cảm ơn, câu trả lời này hữu ích cho tôi – mahdi

+2

Tốt nhất để sử dụng @android: màu/trong suốt thay vì # 00xxxxxx –

3

android: background = "# 00000000" android: cacheColorHint = "# 00000000"

điều này sẽ làm là minh bạch tuy nhiên, đây là làm cho nó một sự minh bạch đầy đủ ...