relativelayout 内的 Imageview,嵌套在 LinearLayout 内
我的目标是在屏幕上的一行上显示 6 个图像(1 个图像,6 次)。我的方法是将relativelayout嵌套在LinearLayout中。我的问题是,当我处于“肖像”模式时,我无法看到所有图像。我调整图像大小的次数越多,可以容纳的图像就越多,但我现在不希望它变得更小。我认为默认情况下,它只会包装它无法容纳的内容,但情况似乎并非如此。没有自动调整大小以适应?另外,如何手动确定每个图像之间的空间有多少?谢谢!
My goal is to display 6 images (1 image, 6 times) across one line on my screen. My approach was to nest a RelativeLayout inside of a LinearLayout. My issue is that when I'm in 'portrait' mode, I cannot see all of my images. The more I resize my image, the more of the images I can fit, But I'm at a point where I do not want it to be any smaller. I assumed that by default, it would just wrap what it can't fit, but that doesnt seem to be the case. Theres no auto re-size to fit? Also, how can I manually decide how much space is between each image? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您需要为您的应用程序提供两个不同的 xml 文件,一个用于纵向,一个用于横向,如下所示: 提供资源。 android 将根据方向选择正确的 xml 文件。
这个 ImageView.ScaleType 解释了不同的缩放样式,
这就是我建议:
weight
元素应该使它们全部适合,但可能与scaleType
发生冲突。无论如何,这应该适用于您的风景,对于肖像,您可以使其有两行图像,或者您可以使用horizontalScrollView
如下所示:真的,您可能只使用肖像
main.xml
作为您唯一的布局文件,并且无论方向如何,都可以水平滚动。您可能需要在肖像main.xml
中进行一些更改,因为我正在工作,并且我不确定weight
与horizontalScrollView
的配合效果如何至于每个元素之间的空间,您可以使用 android:padding< /a> 就像我上面那样。
Basically, you need to provide two different xml files for your app, one for portrait, once for landscape as per: Providing Resources. android will pick the proper xml file based on orientation.
and this ImageView.ScaleType explains the different scaling styles
Here is what I would suggest:
the
weight
element should make them all fit but there might be a conflict withscaleType
. anyway that should do it for your landscape, for portrait, you could either make it so there were two rows of images, or you could use ahorizontalScrollView
as below:really, you could prolly just use the portrait
main.xml
as your only layout file and just have it be horizontally scrolling regardless of orientation. you might need to change some times in the portraitmain.xml
as i am at work and im not sure how wellweight
works withhorizontalScrollView
as far as the space between each element, you would use android:padding like i have above.