修改Gallery2记录

1. 修改ActionBar的背景色,本例为修改为红色#ffff0000,也可以指定到/res/drawable/xx.png
1). 在Gallery2/res/values/ 增加自己的资源文件theme.xml
<?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
<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
<?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
<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
<?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
<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
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
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
<!-- 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>		<!-- 相册缩略图的间隙-->


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
dosamigos/gallery 是一个 Yii2 扩展,用于创建和显示图片相册。它提供了一个名为 `Gallery` 的小部件(widget),可以轻松地在 Yii2 应用程序中集成和使用。 使用 dosamigos/gallery 扩展的步骤如下: 1. 安装扩展:通过 Composer 在你的 Yii2 项目中安装 dosamigos/gallery 扩展。可以在终端中使用以下命令进行安装: ```shell composer require 2amigos/yii2-gallery ``` 2. 配置扩展:在你的应用程序的配置文件(通常是 `config/web.php` 或 `config/main.php`)中添加 dosamigos/gallery 组件的配置。例如: ```php 'components' => [ // 其他组件配置... 'gallery' => [ 'class' => 'dosamigos\gallery\GalleryManager', // 可选配置... ], ], ``` 在上述配置中,我们将 `gallery` 组件的类设置为 `dosamigos\gallery\GalleryManager`。你还可以根据需要进行其他可选的配置。 3. 使用小部件:在视图文件中使用 `Gallery` 小部件来显示图片相册。例如: ```php use dosamigos\gallery\Gallery; // ... echo Gallery::widget([ 'items' => $items, 'options' => ['class' => 'gallery-widget'], ]); ``` 在上述代码中,我们使用 `Gallery` 小部件并指定图片项数组 `$items`。你可以根据自己的需求修改和替换 `$items`。 另外,我们还可以使用 `'options'` 参数来指定小部件的配置选项。在上述示例中,我们将 `class` 设置为 `gallery-widget`,你可以根据你的样式需求进行修改。 通过以上步骤,你可以在你的 Yii2 应用程序中使用 dosamigos/gallery 扩展来创建和显示图片相册。记得在视图文件中替换和配置 `$items` 为你自己的图片项数组,并根据需要进行其他的小部件和样式配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值