1

万岁图片!这是将图片分配给背景时的样子,以及没有时的样子。

在此处输入图像描述

在此处输入图像描述

TableView如果图像大于桌子,我非常希望它不会伸出顶部。我已经包含了一个空的“视图”,以便为表格的背景提供一点额外的空间,正如您在下面的 XML 中看到的那样。试图弄乱 ScaleType,但那是洗礼。

如何让 BG 拉伸以适应布局?我正在尝试优雅地处理“用户 xxx 的屏幕比 WVGA 小”。显然,我缺乏优雅。

<TableLayout
android:id="@+id/widget29"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scaleType="fitXY"
android:background="@drawable/minetownx480"
>
<View
android:id="@+id/blankSpace"
android:layout_width="fill_parent"
android:layout_height="60dip" />

<TableRow android:id="@+id/widget40" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal">
    <TextView android:id="@+id/moneyText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Money: $$$$$$$$$" />
    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content"  android:id="@+id/savingsText"  android:gravity="right"  android:text="Savings: $$$$$$$"  android:layout_weight="3" android:textSize="12sp"/>
</TableRow>

<TableRow android:id="@+id/widget41" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal">
    <TextView android:id="@+id/wagonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Wagon Space: XXX/XXX" />
    <TextView android:id="@+id/loanText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Loans: $$$$$$$$" android:gravity="right" android:layout_weight="3" android:textSize="12sp"/>
</TableRow>

<TableRow android:id="@+id/widget42" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" >
    <TextView android:id="@+id/daysText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Days Left: XX/XX" />
    <TextView android:id="@+id/armedText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Unarmed!" android:gravity="right" android:layout_weight="3" />
</TableRow>
</TableLayout>

tablelayout 是根 linearLayout 的第一个元素,如果这很重要的话。

编辑:或者,如果您知道如何在分配图像之前测量 tableLayout 的 X 和 Y 空间,我可以在分配之前以编程方式对其进行缩放......如果有人知道,这两种解决方案都会很好!

4

1 回答 1

5

我会使用 FrameLayout 并创建两个图层(即在里面添加两个视图)。第一个是 ImageView,第二个是你的桌子。通过这种方式,我不会依赖表格来控制我的图像缩放,但它将独立于 ImageView,然后希望更容易操作它,因为它不是将图像显示为“背景”,而是显示为源。

于 2011-04-24T11:15:50.407 回答