自定义控件:3D画廊Gallery

发布时间:2024-12-19 17:46

艺术爱好者的抽象表现主义画廊巡览 #生活乐趣# #旅行建议# #主题旅游#

自定义控件:3D画廊Gallery

最新推荐文章于 2024-09-20 09:34:33 发布

Jack-Chan 于 2017-02-17 11:19:34 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

gallery gallery

Gallery

This class was deprecated in API level 16.
This widget is no longer supported. Other horizontally scrolling widgets include HorizontalScrollView and ViewPager from the support library.

package com.github.gallery.view; import android.content.Context; import android.graphics.Camera; import android.graphics.Matrix; import android.util.AttributeSet; import android.view.View; import android.view.animation.Transformation; import android.widget.Gallery; import android.widget.ImageView; public class CustomGallery extends Gallery { private int galleryCenterPoint = 0; // gallery的中心点 private Camera camera; public CustomGallery(Context context, AttributeSet attrs) { super(context, attrs); // 启用getChildStaticTransformation被调用 setStaticTransformationsEnabled(true); camera = new Camera(); } /** * 当gallery控件的宽和高改变时回调此方法, 第一次计算出gallery的宽和高时, 也会出发此方法 */ @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); galleryCenterPoint = getGalleryCenterPoint(); } /** * 返回gallery的item的子图形变换效果 * Transformation 指定当前item的变换效果 */ @Override protected boolean getChildStaticTransformation(View child, Transformation t) { int viewCenterPoint = getviewCenterPoint(child); // item的中心点 int rotateAngle = 0; // 默认旋转角度为0 // 如果当前的View的中心点不等于gallery的中心点, 就是两边的图片, 需要计算旋转角度 if(viewCenterPoint != galleryCenterPoint) { // gallery中心点 - 图片中心点 = 差值 int diff = galleryCenterPoint - viewCenterPoint; // 差值 / 图片的宽度 = 比值 float scale = (float)diff / (float)child.getWidth(); // 比值 * 最大旋转角度 = 最终的旋转角度 rotateAngle = (int) (scale * 50); if(Math.abs(rotateAngle) > 50) { // 当前角度超过了50, 需要赋值到50 或者 -50 rotateAngle = rotateAngle > 0 ?

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758

网址:自定义控件:3D画廊Gallery https://www.yuejiaxmz.com/news/view/519754

相关内容

开个“网红画廊” 打造属于自己的艺术生活|涌流2020
如何将画廊装进你的公寓里?
报房胡同里有个家居画廊,能把艺术带回家
纽约切尔西艺术区依旧坚挺?大牌画廊加倍下注
让艺术走近生活 化龙池28号从豆腐作坊蝶变为画廊
一座能让开发者与用户「见面」的数字生活画廊。
自己动手,打造一面ins风的画廊墙吧!
Mesura | 工业公寓改造,艺术画廊与生活空间的完美融合
「画廊制作」画廊制作公司黄页
数字艺术作为切入点设计出画廊与艺术家之间新的利益关系,斩获RCA皇艺服务设计MA Offer

随便看看