我的目標是在屏幕上的一條線上顯示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?