修改Gallery2记录
1. 修改ActionBar的背景色,本例为修改为红色#ffff0000,也可以指定到/res/drawable/xx.png
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <style name="TestAppTheme" parent="android:Theme.Holo.Light">
- <item name="android:actionBarStyle">@style/WindCustomActionbar</item>
- </style>
- <style name="WindCustomActionbar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
- <item name="android:background">#ffff0000</item>
- </style>
- </resources>
2). 在AndroidManifest.xml里指定使用这个Style
[html] view plaincopy
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/TestAppTheme">
- ...
- </application>
2. 修改ActionBar上字体颜色,类似上面的,本例修改为白色
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <style name="TestAppTheme" parent="android:Theme.Holo.Light">
- <item name="android:actionBarStyle">@style/WindCustomActionbar</item>
- </style>
- <style name="WindCustomActionbar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
- <item name="android:titleTextStyle">@style/WindCustomTitleTextColor</item>
- </style>
- <style name="WindCustomTitleTextColor" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
- <item name="android:textColor">@*android:color/white</item>
- </style>
- </resources>
2). 在AndroidManifest.xml里指定使用这个Style
[html] view plaincopy
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/TestAppTheme">
- ...
- </application>
3. 修改选中模式下的ActionBar的背景色,即View.startActionMode后的ActionBar背景色
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
[html] view plaincopy
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <style name="TestAppTheme" parent="android:Theme.Holo.Light">
- <item name="android:actionModeBackground">@drawable/ic_launcher</item>
- </style>
- </resources>
2). 在AndroidManifest.xml里指定使用这个Style
[html] view plaincopy
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/TestAppTheme">
- ...
- </application>
4. 将画布背景从黑色改为白色
修改文件Gallery2/src/com/android/gallery3d/ui/StaticBackground.java
[java] view plaincopy
- protected void render(GLCanvas canvas) {
- //canvas.fillRect(0, 0, getWidth(), getHeight(), 0xFF000000); //0xFF000000为黑色
- canvas.fillRect(0, 0, getWidth(), getHeight(), 0xFFFFFFFF); //0xFFFFFFFF为白色
- }
5. 将缩略图的左边距,上边距,右边距,下边距设定为20dp的空隙
Gallery2/src/com/android/gallery3d/app/AlbumSetPage.java
[java] view plaincopy
- private final GLView mRootPane = new GLView() {
- private final float mMatrix[] = new float[16];
- @Override
- protected void onLayout(
- boolean changed, int left, int top, int right, int bottom) {
- ...
- //mAlbumSetView.layout(0, slotViewTop, slotViewRight, slotViewBottom); //源代码
- //加入左边距,右边距,上边距,下边距
- mAlbumSetView.layout(20, slotViewTop + 20, slotViewRight - 20, slotViewBottom - 20);
- PositionRepository.getInstance(mActivity).setOffset(
- 0, slotViewTop);
- }
- ...
- }
6.将原来的竖屏模式下4行显示改为3行显示,修改缩略图相册间的间隔
Gallery2/res/values/dimensions.xml
[html] view plaincopy
- <!-- configuration for album set page -->
- <integer name="albumset_rows_land">2</integer>
- <integer name="albumset_rows_port">4</integer> <!--将4修改为3 -->
- <dimen name="albumset_slot_gap">1dp</dimen> <!-- 相册缩略图的间隙-->
原文地址:http://blog.csdn.net/androiddeveloper_lee/article/details/9495581