【发布时间】:2011-01-01 14:57:54
【问题描述】:
我有一个当前具有固定大小的 RelativeLayout。指定子视图的宽度、高度、边距、字体高度,因此一切看起来都恰到好处。
我现在想缩放布局(以适应屏幕大小)。布局应该像平面图像一样缩放,因此所有内容都按比例缩小(字体、边距等)
我在下面做了一个简化的例子。缩放到 0.5,这将显示文本“ONE QUARTER”,左边距为 200dip,边距顶部为 120dip。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="1600dip"
android:layout_height="960dip"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:text="ONE QUARTER"
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="400dip"
android:layout_marginTop="240dip"
></TextView>
</RelativeLayout>
当然,我并不是要任何人帮我编写一个算法来缩放所有这些值:只是想知道是否有一些简单的方法可以实现这一点......
谢谢!
【问题讨论】: