### Open Camera Directly by Setting GalleryConfig Flag Source: https://github.com/yancyye/gallerypick/blob/master/README.md This method demonstrates how to configure GalleryPick to directly open the camera by setting the `isOpenCamera` flag within the `GalleryConfig` builder. This is suitable for initial setup where the primary action is to launch the camera. ```groovy GalleryConfig galleryConfig = new GalleryConfig.Builder() .iHandlerCallBack(iHandlerCallBack) // 监听接口(必填) .filePath("/Gallery/Pictures") // 图片存放路径 (选填) .isOpenCamera(true) // 直接开启相机的标识位 .build(); GalleryPick.getInstance().setGalleryConfig(galleryConfig).open(mActivity); ``` -------------------------------- ### Configure Custom Cropping Ratio and Dimensions Source: https://github.com/yancyye/gallerypick/blob/master/README.md This example shows how to customize the cropping box's aspect ratio and dimensions. The `crop` method now accepts parameters for width, height, and output dimensions, allowing for precise control over the cropping area. The cropped images are saved in a 'crop' subdirectory within the specified `filePath`. ```groovy GalleryConfig galleryConfig = new GalleryConfig.Builder() .imageLoader(new GlideImageLoader()) // ImageLoader 加载框架(必填) .iHandlerCallBack(iHandlerCallBack) // 监听接口(必填) .provider("com.yancy.gallerypickdemo.fileprovider") // provider (必填) .pathList(path) // 记录已选的图片 .crop(true, 1, 1, 500, 500) // 配置裁剪功能的参数, 默认裁剪比例 1:1 .isShowCamera(true) // 是否现实相机按钮 默认:false .filePath("/Gallery/Pictures") // 图片存放路径 .build(); GalleryPick.getInstance().setGalleryConfig(galleryConfig).open(mActivity); ``` -------------------------------- ### Open Camera by Modifying Existing GalleryConfig Source: https://github.com/yancyye/gallerypick/blob/master/README.md If a `GalleryConfig` object already exists, this snippet shows how to modify its `isOpenCamera` property using the builder pattern to enable direct camera launch. This is useful for dynamically changing the configuration without rebuilding the entire object. ```groovy galleryConfig.getBuilder().isOpenCamera(true).build(); GalleryPick.getInstance().setGalleryConfig(galleryConfig).open(mActivity); ``` -------------------------------- ### Open Camera Using Dedicated openCamera Method Source: https://github.com/yancyye/gallerypick/blob/master/README.md For convenience, GalleryPick provides a dedicated `openCamera` method that directly launches the camera without requiring modifications to the `GalleryConfig` flags. This simplifies camera access when the existing configuration should remain unchanged. ```groovy GalleryPick.getInstance().setGalleryConfig(galleryConfig).openCamera(mActivity); ``` -------------------------------- ### Customize UI Colors by Overriding XML Resources Source: https://github.com/yancyye/gallerypick/blob/master/README.md This example illustrates how to customize UI elements, such as the title bar color, by overriding resource files. By defining a color resource with the same name (e.g., `gallery_blue`) in the app's `colors.xml`, the library's default color can be replaced, achieving a custom UI appearance. ```xml #FF4081 ``` -------------------------------- ### Configure Basic Image Cropping with GalleryPick Source: https://github.com/yancyye/gallerypick/blob/master/README.md This code snippet demonstrates how to enable the basic image cropping feature in GalleryPick. Cropping is active only in single-selection mode or when directly opening the camera. It requires an ImageLoader, a callback handler, and a provider. ```groovy GalleryConfig galleryConfig = new GalleryConfig.Builder() .imageLoader(new GlideImageLoader()) // ImageLoader 加载框架(必填) .iHandlerCallBack(iHandlerCallBack) // 监听接口(必填) .provider("com.yancy.gallerypickdemo.fileprovider") // provider (必填) .pathList(path) // 记录已选的图片 .crop(true) // 快捷开启裁剪功能,仅当单选 或直接开启相机时有效 .isShowCamera(true) // 是否现实相机按钮 默认:false .filePath("/Gallery/Pictures") // 图片存放路径 .build(); GalleryPick.getInstance().setGalleryConfig(galleryConfig).open(mActivity); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.