2014-09-20 48 views
0

enter image description here使用圖片作爲背景標題欄和頁腳顯示白色墊襯

我想分別以頁眉和頁腳的背景圖像樣式操作欄和頁腳。當通過修改佈局來實現執行時,看起來有些空白不適合外觀。我所有的圖像都使用透明背景的png文件。是否有任何方法來修改頁眉和頁腳背景的透明度?下面的OS我相對佈局結構:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@android:color/transparent" > 

    <!-- Header aligned to top --> 

    <RelativeLayout 
     android:id="@+id/header" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/heading" 
     android:gravity="center" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      android:text="Fixed Header" 
      android:textColor="#000" 
      android:textSize="20sp" /> 
    </RelativeLayout> 

    <!-- Footer aligned to bottom --> 

    <RelativeLayout 
     android:id="@+id/footer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:background="@drawable/footer" 
     android:gravity="center" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_margin="5dp" 
      android:text="Fixed Footer" 
      android:textColor="#000" 
      android:textSize="20sp" /> 
    </RelativeLayout> 

    <!-- Scrollable Item below header and above footer --> 

    <ScrollView 
     android:id="@+id/scrollableContents" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/footer" 
     android:layout_below="@id/header" 
     android:background="#ff5" > 

     <!-- Inflate the contents of the ScrollView dynamicaly --> 

    </ScrollView> 

</RelativeLayout> 

回答

0

&頁腳來自活動背景(因爲列表視圖低於頭以上頁腳)你的頭的白色部分可能使用樣式改變:

定義在RES /價值/ colors.xml自定義顏色

<color name="custom_theme_color">#b0b0ff</color> 

RES /價值/ styles.xml創建樣式

<style name="CustomTheme" parent="android:Theme.Light"> 
    <item name="android:windowBackground">@color/custom_theme_color</item> 
    <item name="android:colorBackground">@color/custom_theme_color</item> 
</style> 

(windowBackground可以是繪製參考太)

中的Manifest.xml設置此風格的活動:

<activity 
    android:name="myActivity" 
    android:theme="@style/CustomTheme"> 

欲瞭解更多詳情,請參閱Android Styles and Themes