首页 > 其他 > 详细

使Gallery时设置居左显示

时间:2014-10-13 21:28:48      阅读:345      评论:0      收藏:0      [点我收藏+]
Gallery中的图片默认是居中显示的,但是在很多情况下我们需要它居左显示,这样做有一个简单方法,就是把Gallery的left设置为负多少,如下面的方法:
Drawable drawable=categoryItem.getCategorys().get(0).getImage();
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
         
MarginLayoutParams mlp=(MarginLayoutParams)gallery.getLayoutParams();
   mlp.setMargins(-(metrics.widthPixels / 2 + drawable.getIntrinsicWidth()), mlp.topMargin,
                    mlp.rightMargin, mlp.bottomMargin);
gallery.setLayoutParams(mlp);

使Gallery时设置居左显示

原文:http://blog.csdn.net/wode_dream/article/details/40050223

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!