我的目标是在屏幕上的一条线上显示6个图像(1个图像,6次)。我的方法是在LinearLayout中嵌套一个RelativeLayout。我的问题是,当我处于“肖像”模式时,我看不到所有的图像。我调整图像的尺寸越大,我可以适应的图像就越多,但是我不希望它变得更小。我认为,默认情况下,它会包装它不适合的东西,但似乎并非如此。 Theres没有自动重新调整大小以适应?另外,如何手动确定每张图像之间有多少空间?谢谢!RelativeLayout中的ImageViews嵌套在LinearLayout中
0
A
回答
0
基本上,您需要为您的应用程序提供两个不同的xml文件,一个用于纵向,一个用于横向格式:Providing Resources。 android会根据方向选择合适的xml文件。
这ImageView.ScaleType解释了不同的缩放风格
这里是我的建议:
res/layout-land/main.xml
<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/debris_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:weight="1"
android:src="@drawable/image1"
</ImageView
... repeat 5 more times ...
</LinearLayout>
的weight
元素应该让他们都保持健康,而且有可能与scaleType
冲突。无论如何应该为你的风景做,人像,你既可以使它所以有图像的两行,或者你也可以如下使用horizontalScrollView
:
res/layout-port/main.xml
<?xml version="1.0" encoding="utf-8" ?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/debris_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:weight="1"
android:padding="15dp"
android:src="@drawable/image1"
</ImageView
... repeat 5 more times ...
</LinearLayout>
</HorizontalScrollView>
真的,你可以prolly只使用肖像main.xml
作为您唯一的布局文件,并且无论方向如何都可以水平滚动。您可能需要更改一些时间在肖像main.xml
因为我在工作和林不知道如何与weight
horizontalScrollView
工作尽可能的每个元素之间的空间,你可以使用android:padding像我上面都有。
相关问题
- 1. 如何避免嵌套的LinearLayout或RelativeLayout
- 2. 在LinearLayout中拉伸ImageViews
- 3. Android - LinearLayout在ScrollView中的Relativelayout
- 4. 将LinearLayout与LinearLayout在RelativeLayout中对齐
- 5. LinearLayout中的ImageViews - 搞乱了规模
- 6. 在LinearLayout中居中多个RelativeLayout
- 7. LinearLayout vs RelativeLayout
- 8. RelativeLayout或LinearLayout?
- 9. 如何将RelativeLayout中的LinearLayout居中?
- 10. 采取嵌套的RelativeLayout
- 11. 使用嵌套的LinearLayout
- 12. 嵌套的LinearLayout不可见
- 13. 重量比例在嵌套的LinearLayout
- 14. 滚动通过在嵌套的LinearLayout
- 15. android嵌套LinearLayout调整
- 16. 帮助Android的LinearLayout或RelativeLayout
- 17. 在LinearLayout中嵌套列表视图和LinearLayout会产生用户界面问题
- 18. 嵌套视图的RelativeLayout规则
- 19. GLSurfaceView父类即使嵌套在LinearLayout中也为null
- 20. 如何在RelativeLayout中添加LinearLayout,其中动态内容是从DB中的Relativelayout中加载的?
- 21. 在Relativelayout中的ImageViews是重叠的。我想将较低的imageView放在顶部
- 22. 在完全占用的LinearLayout中添加RelativeLayout
- 23. RelativeLayout vs嵌套线性布局性能
- 24. 两个或更多嵌套RelativeLayout
- 25. 在嵌入式LinearLayout中使用的onClick
- 26. 动态添加的LinearLayout成的RelativeLayout
- 27. 使用RelativeLayout和LinearLayout在Android中正确装饰视图
- 28. 如何以编程方式在RelativeLayout中添加LinearLayout?
- 29. Android:我如何在LinearLayout中定义45°视角(RelativeLayout)
- 30. ConstraintLayout不能代替RelativeLayout或LinearLayout?