2013-06-04 223 views
1

嗨,大家好我想調整大小樣式的圖像背景,我有一個使用的樣式和節目的背景圖像調整大小背景圖片

風格的形象圖:

<style name="Background"> 
     <item name="android:layout_width">match_parent</item> 
     <item name="android:layout_height">50dp</item> 
     <item name="android:orientation">horizontal</item> 
     <item name="android:background">@drawable/img_background</item> 
    </style> 

所以我有「img_background」,它的尺寸約爲1920 * 1080,我想調整它的大小以適應所有設備尺寸,如何根據屏幕尺寸自動調整大小?,因爲它不起作用 它不正確顯示圖像的方式是不正確的,並且沒有適當調整大小以適應屏幕。

我有一個LinearLayout,它具有樣式,然後在其中的圖像視圖。它不適合1920 * 1080的正確,例如在800 * 480的分辨率就被裁剪掉,而不是整齊地調整

<LinearLayout 

      style="@style/Background" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      > 





      <ImageView 

       android:contentDescription="@null" 
       android:layout_marginBottom="8dip" 
       android:layout_marginLeft="8dp" 
       android:layout_marginRight="8dip" 
       android:layout_marginTop="8dip" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:clickable="false" 
       android:paddingLeft="15dip" 
       android:src="@drawable/img_background" 
       /> 

     </LinearLayout> 

感謝

+0

使用: 的android:layout_width = 「match_parent」 和 機器人:layout_height = 「match_parent」 – user1283633

+0

你想它只能是50dp高? –

+0

是的我的Imageview很小,我希望寬度能夠正確調整大小,圖像是一個橫幅,它的寬度很長, –

回答

0

LinearLayout

戴上取下風格這是您的ImageView:

<ImageView 
    android:contentDescription="@null" 
    android:layout_marginBottom="8dip" 
    android:layout_marginLeft="8dp" 
    android:layout_marginRight="8dip" 
    android:layout_marginTop="8dip" 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:clickable="false" 
    android:paddingLeft="15dip" 
    android:scaleType="centerInside" 
    android:src="@drawable/img_background" /> 
+0

謝謝,但沒有工作,我正在使用線性佈局應用該樣式,然後將ImageView Inside。像這樣檢查OP更新 –

0

變化layout_width和layout_height你的XML

<item name="android:layout_width">fill_parent</item> 
<item name="android:layout_height">fill_parent</item> 
+0

嗨,沒有工作,檢查OP我更新它更多信息謝謝 –