2011-04-09 86 views
0

基本上我有一系列的線性佈局圖像。我已將每個圖像瀏覽佈局寬度和佈局高度屬性分別設置爲100dp和50dp(我也嘗試過使用px代替dp,並且我試圖更改圖像瀏覽最大大小),但圖像瀏覽繼續縮放而不是停留在這個固定的大小。防止Android UI縮放

我只是想知道如果有人知道我做錯了什麼?

XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/backgroundtop" android:gravity="bottom"> 
    <FrameLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/frameLayout1"> 
     <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageView3" android:src="@drawable/base" android:layout_gravity="center"></ImageView> 
     <LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center" android:paddingTop="50px" android:layout_width="match_parent"> 
      <ImageView android:src="@drawable/buttonnews" android:id="@+id/imageView1" android:layout_width="123dp" android:layout_height="49dp" android:scaleType="center"></ImageView> 
      <ImageView android:id="@+id/imageView2" android:layout_width="163dp" android:layout_height="49dp" android:src="@drawable/buttonevents"></ImageView> 
     </LinearLayout> 
    </FrameLayout> 
</LinearLayout> 
+0

你正在測試什麼設備?你的清單中的minSdkVersion/targetSdkVersion設置爲什麼?如果您省略這兩個聲明,則Android會在運行時假定您的應用程序定位API 1,並縮放您的UI以模擬320x480屏幕。 – adamp 2011-04-09 20:04:48

回答

0

您是否嘗試過的ImageView的scaleType設置爲fitCenter?測量的

+0

我剛纔試過了。不幸的是它仍然不起作用。 – Bob 2011-04-09 15:37:44

+0

縮放圖像它將解決您的問題。 – Vivek 2011-04-09 17:59:14

0

單位Android支持可以是:

PX
像素 - 對應於屏幕上的實際像素。

in
英寸 - 基於屏幕的物理尺寸。

mm
毫米 - 基於屏幕的物理尺寸。

pt
Points - 基於屏幕物理尺寸的1/72英寸。

DP
密度獨立像素 - 即是基於屏幕的物理密度的抽象單元。這些單位相對於160 dpi屏幕,所以一個dp是160 dpi屏幕上的一個像素。 dp到像素的比例將隨着屏幕密度而改變,但不一定是直接的;相反,選擇比率是接近屏幕的東西。

SP
量表無關的像素 - 這是像DP單元,但它也由用戶的字體大小偏好縮放。建議您在指定字體大小時使用本機,以便根據屏幕密度和用戶偏好進行調整。