我知道互聯網充斥着有關DPI px英寸等問題。 但經過幾個小時的谷歌搜索,我的情況似乎並沒有發生在其他人身上!相同的DPI,但不同的英寸大小
我有2個設備自定義生成與Android工作室都是mdpi。 但一個設備是3.65英寸,另一個設備是10.1英寸。
我創建了一個文件夾2個圖像250x125與DPI設置爲160 dpi的
如果通常我會在我的XML與dp爲單位而不是像素宣佈我的2張圖片...我想在兩個屏幕上結果應該是一樣的權利?
那麼它似乎圖像保留其餘相同大小和不看@設備多少寸
清楚,所以把事情: 什麼我有我的資源或我的代碼來改變,因此我的佈局縮放比例是否相同?
我怎樣才能讓這個即使是3.65英寸的屏幕上按鈕將縮放到與10.1相同的比例。不是英寸...不...像素的比例....
這是我的XML文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/buttonEnglish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/english"
android:layout_marginBottom="5sp"
android:layout_marginLeft="5sp"
android:layout_marginRight="2sp"
android:layout_marginTop="0sp" />
<Button
android:id="@+id/buttonNederlands"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/nederlands"
android:layout_marginBottom="5sp"
android:layout_marginLeft="20sp"
android:layout_marginRight="5sp"
android:layout_marginTop="0sp"
/>
</LinearLayout>
我絕望... Thanx提前
用心看你的按鈕尺寸。這些尺寸保持不變。但由於屏幕尺寸不同,小尺寸屏幕看上去像按鈕。其實你需要設計兩個XML佈局。一個用於平板電腦,一個用於手機。 – Amir
因此,對於市場上手機或平板電腦的每種可能的尺寸,我需要創建一個不同的XML文件?這是maddnes xo! – Fosa
您對UI應該如何在Android中進行佈局的理解是錯誤的 - 對於按鈕或其他UI組件來說,使用屏幕尺寸進行線性縮放絕對沒有意義。請參閱[http://developer.android.com/guide/practices/screens_support.html](http://developer.android.com/guide/practices/screens_support.html)和大量教程網站以瞭解更多信息。 – Kai