FAQ13715][Gallery] 如何修改gallery的背景色

来源:互联网 发布:淘宝的垃圾箱在哪里 编辑:程序博客网 时间:2024/05/29 13:26
Gallery的背景色定义在:
Gallery2/res/values/colors.xml 文件中
 
     <!-- configuration for album set page -->
    <color name="albumset_background">#1A1A1A</color>
 
    <!-- configuration for album page -->
    <color name="album_background">#1A1A1A</color>
 
    <!-- configuration for photo page -->
    <color name="photo_background">#1A1A1A</color>
 
上述3个定义分别对应了gallery3个page的背景色;
如果需要修改背景色为黑色,则需要将对应值修改为#000000
如果需要修改背景色为白色,则需要将对应值修改为#FFFFFF
 
L版本补充说明:
在L版本Photopage页面,背景色不再从上述文件中获得,则第三项修改不起效;
请参照如下方式进行修改:
PhotoPage.java
protected float[] getBackgroundColor() {
    if (mModel != null && mModel.isCamera(0)) {
        mPhotoPageBackgroundColor[0] = 0.0f;
    } else {
        mPhotoPageBackgroundColor[0] = 1.0f;
        mPhotoPageBackgroundColor[1] = 1.0f;
        mPhotoPageBackgroundColor[2] = 1.0f;
        mPhotoPageBackgroundColor[3] = 1.0f;
        Log.d(TAG, "PhotoPage.getBackgroundColor");
    }
    mBackgroundColor = mPhotoPageBackgroundColor;
    return mPhotoPageBackgroundColor;
}
如上蓝色标示位置,都修改为1.0f则是白色;如果都修改为0.0f则是对应黑色
 
 
补充问题分析:
修改整个window的theme为白色,再修改以上背景色为白色后,进入gallery时仍会闪出一帧黑色背景:
可尝试修改Gallery2/res/layout/gl_root_group.xml文件如下:
    <View android:id="@+id/gl_root_cover"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
     android:background="@android:color/black"  
            android:visibility="gone"/>
请将android:background="@android:color/black"  颜色修改为白色
0 0
原创粉丝点击