简体   繁体   English

在Android中自定义图片库

[英]Customizing an image gallery in android

I swear, this control has been the bane of my existance this week. 我发誓,这种控制权是本周我生存的祸根。 Just FYI, I have pretty basic OO/Java skills, I've mainly been using xml to create layouts, but I need to use the gallery control. 仅供参考,我具有基本的OO / Java基本技能,我主要使用xml创建布局,但是我需要使用gallery控件。 I've finally got the sample code working from the sdk, but one thing remains a mystery despite looking here, googling elsewhere, etc., there seems to be no clear answer on how you exactly manipulate the attributes of individual images within the gallery. 我终于从sdk中获得了示例代码,但是尽管在这里看,在其他地方使用谷歌搜索等等,还有一件事仍然是个谜,关于如何正确操作画廊中单个图像的属性似乎没有明确的答案。 I keep looking for an example of a template that I could implement, but see nothing. 我一直在寻找可以实现的模板示例,但是什么也没看到。 Really, I'm not looking for anything fancy, I just want the images to scale properly within a fixed height gallery control, and surround each image with a 1dip light border, and keep each of them about 4dip apart from one another, that's about it. 真的,我不是想找任何花哨的东西,我只是想让图像在固定高度的画廊控件中正确缩放,并用1dip浅边框包围每个图像,并使每个图像彼此相距约4dip,即它。 But for the life of me I'm just not seeing how to make these customizations, and I'm starting to tear my hair out! 但是对于我的一生,我只是不知道如何进行这些自定义,并且我开始扯头发! :-/ Any help or reference to how to do this with some actual examples would be priceless! :-/任何帮助或参考如何通过一些实际的例子来做到这一点都是无价的!

Yeah, just to continue on your own answer. 是的,继续您自己的回答。

The getView() method of the adapter is the place where you'll do anything you want with the images, ie set up borders, layout params, lazy loading, etc. 适配器的getView()方法是您要对图像进行任何操作的地方,即设置边框,布局参数,延迟加载等。

As long as the method returns the View you've made changes to, it should work just fine. 只要该方法返回您已对其进行更改的View ,它就可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM