我的xml在android stux nexus 7和nexus 10模擬器上工作得很好,xml在我的nexus 4上運行得很好。但是當我在7英寸平板電腦僅在y方向上延伸我的圖像(在橫向活動中)並且不保持寬高比。我試過兩種不同的7英寸平板電腦,結果相同。我想我已經嘗試將佈局寬度和佈局高度更改爲幾乎所有可能的組合。如果我用imageview而不是imagebutton嘗試它,我也有相同的縮放比例問題。我使用Google搜索並嘗試了一切,但沒有找到適合我的解決方案。請幫我...當我使用scale時,我的horizontalscrollview伸展我的imagebuttons:fitxy
這裏是我的xml:
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/horizontalScrollView"
android:scrollbars="none"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:measureWithLargestChild="false">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageButton2"
android:src="@drawable/mainmenu1"
android:background="@android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:onClick="goToLab101" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageButton3"
android:src="@drawable/mainmenu2"
android:background="@android:color/transparent"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:onClick="goToPeriodicTable" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageButton4"
android:src="@drawable/mainmenu3"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:scaleType="fitXY"
android:onClick="goToLab102"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageButton5"
android:src="@drawable/fountainselector"
android:background="@android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageButton6"
android:src="@drawable/mainmenu5comingsoon"
android:background="@android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:onClick="goToLab103"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/imageButton7"
android:src="@drawable/mainmenu6"
android:background="@android:color/transparent"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
</LinearLayout>
</HorizontalScrollView>
嘗試翻轉這些值的android:layout_width =」 wrap_content「 android:layout_height =」match_parent「to android:layout_width =」match_parent「 android:layout_height =」wrap_content「 – 2014-09-21 04:43:02