2015-05-26 64 views
0

進出口面臨的一個大問題:Android的圖形佈局圖像

我創建一個背景圖像繪製,xxhdpi:1920×1080,並繼續與xhdpi 1280×720和960×540華電國際。背景圖像有一個方形的繪製,在那裏放置一個按鈕。

xxhdpi中按鈕的圖像是360x126,xhdpi 240x84和hdpi 180x63。

問題出在hdpi。如果我使用具有分辨率960x540的設備,圖像按鈕看起來不錯。 但是,當我在三星S2具有480x800的分辨率測試時,背景圖像調整大小以適應解決方案,但圖像按鈕沒有。圖像按鈕仍然是180x63,顯然不適合背景圖像的繪製平方。 我需要的是,按鈕的圖像調整大小取決於屏幕的分辨率。我認爲android會自動執行此操作。

活動代碼:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/background_image" 
tools:context="com.trucouruguayo.MainActivity" > 

<Button 
    android:id="@+id/buttonPlay" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentTop="true" 
    android:layout_marginRight="8dp" 
    android:layout_marginTop="109dp" 
    android:background="@drawable/btn_play" 
    android:minHeight="0dp" 
    android:minWidth="0dp" 
    android:onClick="goToPlay" /> 

你如何使用背景圖片請幫

+0

你使用 – nifCody

+0

這IDE我想不aumatically鏈接的解決方案插件。它必須取決於你的不同文件夾中的可繪製。你可以把你的佈局和一些代碼? –

+0

我正在使用Eclipse。 – user3240604

回答

0

? Android並不擅長縮放Views的背景。如果你想正確對齊圖像,你應該使用ImageView,它有一個scaleType屬性,允許你定義如何處理不同的佈局大小和高寬比。

+0

'ImageButton'也支持'scaleType',如果僅僅是因爲這個原因,不需要改變爲'ImageView'。 – hardartcore

+0

我編輯我的問題並添加代碼 – user3240604

0

問題在於您的繪圖目錄中沒有的不同分辨率圖像。

如果您正在使用Android Studio。使用Android Drawable Image uploader插件上傳圖片它可以處理類似的問題。

這裏是Android工作室https://plugins.jetbrains.com/plugin/7658?pr=