2012-08-10 106 views
0

在我的應用程序中,我正在使用圖像。我不希望圖像的寬度超過任何密度的任何屏幕尺寸的屏幕寬度。如何實現這一點,什麼將是問題,因爲我只使用一個圖像的所有android密度,而不是不同分辨率的圖像?將圖像的寬度限制爲屏幕寬度

回答

0

試試這個,但你需要一個調整圖像的每個分辨率

華電國際,LDPI,MDPI和xdpi分辨率

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/title_bar" 
    android:gravity="center_vertical" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:contentDescription="@string/desc" 
     android:src="@drawable/YourPicSource" /> 

</RelativeLayout> 
+0

有什麼辦法避免這種情況?什麼「wrap_content」實現? – 2012-08-10 10:53:19

+0

wrap_content被你的真實圖像寬度所取代,如果你想在所有的屏幕上改變wrap_content與match_parent或fill_parent我希望能幫助你 – 2012-08-10 10:59:31