2014-09-21 27 views
0

我的xml在android stux nexus 7和nexus 10模擬器上工作得很好,xml在我的nexus 4上運行得很好。但是當我在7英寸平板電腦僅在y方向上延伸我的圖像(在橫向活動中)並且不保持寬高比。我試過兩種不同的7英寸平板電腦,結果相同。我想我已經嘗試將佈局寬度和佈局高度更改爲幾乎所有可能的組合。如果我用imageview而不是imagebutton嘗試它,我也有相同的縮放比例問題。我使用Google搜索並嘗試了一切,但沒有找到適合我的解決方案。請幫我...當我使用scale時,我的horizo​​ntalscrollview伸展我的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> 
+0

嘗試翻轉這些值的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

回答

0

在繪製-大xhdpi添加您的同一圖像繪項目7英寸平板電腦支持

+0

是的,我曾嘗試將更大的圖像文件添加到xhdpi文件夾,但這似乎沒有'修復我的問題。我的問題是我的源圖像尺寸不足以在縮放以適合XY時保持寬高比。之所以添加更大的圖像並不能解決我的問題,因爲我需要「清理」我的項目,以便在我的設備上運行時開始使用更大的圖像。不幸的是,我花了幾個小時試圖解決問題之後才清理我的項目。 – hartrw 2014-09-21 04:59:05

相關問題