修改Gallery2記錄

 

修改Gallery2記錄

 
1. 修改ActionBar的背景色,本例爲修改成紅色#ffff0000,也能夠指定到/res/drawable/xx.png
1). 在Gallery2/res/values/ 增長本身的資源文件theme.xml
[html]  view plain copy
  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
[html]  view plain copy
  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
[html]  view plain copy
  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
[html]  view plain copy
  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
[html]  view plain copy
  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
[html]  view plain copy
  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
[java]  view plain copy
  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
[java]  view plain copy
  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
[html]  view plain copy
  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/9495581html

相關文章
相關標籤/搜索