2014-09-20 44 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