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を使用して、2つのレイヤーを作成します(つまり、内部に2つのビューを追加します)。最初はImageViewになり、2番目、つまり一番上のものがテーブルになります。このように、画像のスケーリングを制御するためにテーブルに依存することはありませんが、画像を「背景」としてではなくソースとして表示するため、ImageViewから独立しているため、より簡単に操作できます。

于 2011-04-24T11:15:50.407 に答える