一個讓我嘮叨了幾周的問題,嘗試了一切,但無濟於事。Android佈局在所有屏幕尺寸上都具有相同的相同尺寸
我想要做的是在每個屏幕尺寸上都有完全相同的佈局。讓我用圖片說明:
在一個2.7英寸設備:
在一個10.1英寸設備(用於說明目的嚴重Photoshop處理圖像):
但與目前的Android實現,我得到這個在10.1英寸的設備上:
總之,我希望我的應用程序看起來相同(相對來說)包括按鈕尺寸,文本縮放e tc等所有屏幕尺寸。我之前通過重寫View類,創建了自己的View並繪製了所有內容,但通過該方法添加視圖元素的速度非常快,並且具有「onClick」回調函數的優勢也消失了(因爲我只是以編程方式在被覆蓋的View類中引入位圖以用作按鈕)。有沒有什麼辦法可以實現這個使用android xml文件?
這裏是我的(測試)XML代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center">
<Button
android:id="@+id/button_1"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1"
android:text="ABCDEF" />
<Button
android:id="@+id/button_2"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1"
android:text="GHI" />
<Button
android:id="@+id/button_3"
android:layout_height="fill_parent"
android:layout_width="0dip"
android:layout_weight="1"
android:text="JKLM" />
</LinearLayout>
您可以通過檢測屏幕大小/分辨率以編程方式更改文本大小及其縮放? – SALMAN 2012-07-24 20:16:46