修改Gallery2记录

 

修改Gallery2记录

 
1. 修改ActionBar的背景色,本例为修改为红色#ffff0000,也可以指定到/res/drawable/xx.png
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.     <resources>  
  3.         <style name="TestAppTheme" parent="android:Theme.Holo.Light">  
  4.             <item name="android:actionBarStyle">@style/WindCustomActionbar</item>  
  5.         </style>  
  6.           
  7.         <style name="WindCustomActionbar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">  
  8.             <item name="android:background">#ffff0000</item>  
  9.         </style>  
  10.     </resources>  

2). 在AndroidManifest.xml里指定使用这个Style
  1. <application  
  2.         android:allowBackup="true"  
  3.         android:icon="@drawable/ic_launcher"  
  4.         android:label="@string/app_name"  
  5.         android:theme="@style/TestAppTheme">  
  6.         ...  
  7.     </application>  

2. 修改ActionBar上字体颜色,类似上面的,本例修改为白色
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.     <resources>  
  3.         <style name="TestAppTheme" parent="android:Theme.Holo.Light">  
  4.             <item name="android:actionBarStyle">@style/WindCustomActionbar</item>  
  5.         </style>  
  6.           
  7.         <style name="WindCustomActionbar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">  
  8.             <item name="android:titleTextStyle">@style/WindCustomTitleTextColor</item>  
  9.         </style>  
  10.           
  11.         <style name="WindCustomTitleTextColor" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">  
  12.             <item name="android:textColor">@*android:color/white</item>  
  13.         </style>  
  14.     </resources>  

2). 在AndroidManifest.xml里指定使用这个Style
  1. <application  
  2.         android:allowBackup="true"  
  3.         android:icon="@drawable/ic_launcher"  
  4.         android:label="@string/app_name"  
  5.         android:theme="@style/TestAppTheme">  
  6.         ...  
  7.     </application>  
    
3. 修改选中模式下的ActionBar的背景色,即View.startActionMode后的ActionBar背景色
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.     <resources>  
  3.         <style name="TestAppTheme" parent="android:Theme.Holo.Light">  
  4.             <item name="android:actionModeBackground">@drawable/ic_launcher</item>  
  5.         </style>  
  6.     </resources>  

2). 在AndroidManifest.xml里指定使用这个Style
  1. <application  
  2.         android:allowBackup="true"  
  3.         android:icon="@drawable/ic_launcher"  
  4.         android:label="@string/app_name"  
  5.         android:theme="@style/TestAppTheme">  
  6.         ...  
  7.     </application>  
    
4. 将画布背景从黑色改为白色
修改文件Gallery2/src/com/android/gallery3d/ui/StaticBackground.java
  1. protected void render(GLCanvas canvas) {  
  2.         //canvas.fillRect(0, 0, getWidth(), getHeight(), 0xFF000000);   //0xFF000000为黑色  
  3.         canvas.fillRect(0, 0, getWidth(), getHeight(), 0xFFFFFFFF); //0xFFFFFFFF为白色  
  4.     }  

5. 将缩略图的左边距,上边距,右边距,下边距设定为20dp的空隙
Gallery2/src/com/android/gallery3d/app/AlbumSetPage.java
  1. private final GLView mRootPane = new GLView() {  
  2.         private final float mMatrix[] = new float[16];  
  3.   
  4.   
  5.         @Override  
  6.         protected void onLayout(  
  7.                 boolean changed, int left, int top, int right, int bottom) {  
  8.            ...  
  9.   
  10.   
  11.             //mAlbumSetView.layout(0, slotViewTop, slotViewRight, slotViewBottom);  //源代码  
  12.             //加入左边距,右边距,上边距,下边距  
  13.             mAlbumSetView.layout(20, slotViewTop + 20, slotViewRight - 20, slotViewBottom - 20);      
  14.             PositionRepository.getInstance(mActivity).setOffset(  
  15.                     0, slotViewTop);  
  16.         }  
  17.         ...  
  18.       }  

6.将原来的竖屏模式下4行显示改为3行显示,修改缩略图相册间的间隔
Gallery2/res/values/dimensions.xml
  1. <!-- configuration for album set page -->  
  2.     <integer name="albumset_rows_land">2</integer>  
  3.     <integer name="albumset_rows_port">4</integer>  <!--将4修改为3 -->  
  4. <dimen name="albumset_slot_gap">1dp</dimen>     <!-- 相册缩略图的间隙-->  

原文地址:http://blog.csdn.net/androiddeveloper_lee/article/details/9495581

原文地址:https://www.cnblogs.com/116913829/p/4267849.html