我想爲兩個imageView並排排列的Android應用程序創建一個Activity。我目前的佈局配置如下:Android - 兩個ImageViews並排
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:paddingTop="15dip" android:paddingBottom="15dip"
android:background="@drawable/dark_bg">
<ImageView android:id="@+id/numberDays"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:scaleType="fitStart"
android:src="@drawable/counter_01" />
<ImageView android:src="@drawable/counter_days"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:scaleType="fitStart"
android:id="@+id/daysText"></ImageView>
</LinearLayout>
第一個圖像將是一個正方形(可以說100×100)和第二圖像將是矩形(300x100的) - 我希望他們能夠彼此相鄰排列,但總是被縮放以適應設備的寬度 - 這可能只是佈局配置?
當前的配置只顯示第一個圖像的整個寬度(和幾乎高度)的屏幕和第二個圖像根本沒有顯示。我試圖用fill_parent和hardocding寬度來改變wrap_content,但是這只是導致兩個圖像都顯示出來,但是第一個圖像位於第二個圖像的頂部(都停住了左側)。
感謝
再次更新:
我已經更新了我的佈局看現在這個樣子,包括了滾動的建議,但沒有喜悅:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:gravity="top"
android:layout_width="fill_parent" android:layout_height="fill_parent" >
<!-- Header for activity - this has the countdown in it -->
<ScrollView android:id="@+id/ScrollView01" android:layout_height="wrap_content" android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"
android:gravity="right"
android:background="@drawable/dark_bg" android:orientation="horizontal">
<ImageView android:id="@+id/numberDays"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="2"
android:src="@drawable/counter_01" />
<ImageView android:src="@drawable/counter_days"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/daysText"/>
</LinearLayout>
</ScrollView>
<!-- main body for the rest of the info -->
<LinearLayout android:orientation="horizontal" android:gravity="center"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/light_bg">
</LinearLayout>
</LinearLayout>
使用layout_weight的建議已經給了這兩個圖像的比例正確,並且看起來完美地縮放了,但是,我仍然遇到了這樣的問題,即它們都被錨定在最左邊的屏幕,所以第一個圖像實際上疊加在第二個圖像的頂部,而不是並排放在一起。
下面是Eclipse顯示的屏幕截圖:
謝謝 - 正如在更新的OP中指出的那樣,重量已經正確地縮放了圖像,但是我仍然遇到第一個(和更小)圖像出現在第二個頂部而不是並排 - 任何想法? – rhinds 2011-06-03 13:49:54
嘗試在'ScrollView'中包含'LinearLayout' – binnyb 2011-06-03 15:06:42
仍然沒有滾動視圖的喜悅 - 我更新了OP以顯示當前配置以及UI當前的外觀樣式的屏幕截圖 – rhinds 2011-06-03 20:04:17