
<gallery xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:ID="@+ID/Horizontalgallery" androID:gravity="center_vertical" androID:spacing="2px"/>@H_301_7@在getvIEw上你必须: @H_301_7@
public VIEw getVIEw(int position,VIEw convertVIEw,VIEwGroup parent) {ImageVIEw i = new ImageVIEw(_Context);i.setimageResource(R.drawable.YourPicture);i.setLayoutParams(new gallery.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));//setting the scale:int vIEwWIDthtmp;int vIEwHeighttmp;if(getHeight() == 0){ if(_horizgallery.getWIDth() == 0){ vIEwWIDthtmp = _horizgallery.getWIDth(); vIEwHeighttmp = _horizgallery.getHeight(); } else { vIEwWIDthtmp = _screenWIDth; vIEwHeighttmp = _screenHeight; }//getting the size of the image.BitmapFactory.Options o = new BitmapFactory.Options();o.inJustDecodeBounds = true; //returns null,but fills the out methodsbm = BitmapFactory.decodeResource(getResources(),R.drawable.YourPicture,o);if(o.outHeight> vIEwHeight || o.outWIDth> vIEwWIDth) {i.setScaleType(ImageVIEw.ScaleType.CENTER_INSIDE);}else {i.setScaleType(ImageVIEw.ScaleType.FIT_CENTER);}//DO NOT ADD the line below//i.setBackgroundResource(mgalleryItemBackground);return i;} @H_301_7@您还必须声明2个全局变量变量并在活动的OnCreate中初始化它们. @H_301_7@ public class Scrollinggallery extends Activity{ private int _screenWIDth; private int _screenHeight;... public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.scrollingallery); display display = getwindowManager().getDefaultdisplay(); _screenWIDth = display.getWIDth(); _screenHeight = display.getHeight();... @H_301_7@之后,您只需要使用计时器制作图库滚动. @H_301_7@如果我没有弄错的话,这应该适用于整页画廊.代码有点长,我只是写了它,所以可能有一个BUG. 总结 以上是内存溢出为你收集整理的在图像android之间滑动全部内容,希望文章能够帮你解决在图像android之间滑动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)