一个让我唠叨了几周的问题,尝试了一切,但无济于事。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