0

私のアプリケーションは、いくつかのデバイスで gridview リストを表示します。各デバイスには 4 つの状態があります。さまざまな種類のデバイス イメージと 4 つの状態イメージがあります。デバイス画像と状態画像を組み合わせてグリッドビューで表示したい。画像はアプリケーション リソースに保存されます。画像は ImageView を使用して表示されます。

どうすればこれを行うことができますか?

画像1

ここに画像の説明を入力

画像2

ここに画像の説明を入力

出力は次のようになります

ここに画像の説明を入力

新しい画像を編集しました

ここに画像の説明を入力 ここに画像の説明を入力 ここに画像の説明を入力

4

2 に答える 2

2

これを試してみてください

public Bitmap combineImages(int boxDrawableId , int closeDrawableId) {

        Bitmap box = BitmapFactory.decodeResource(getResources(),boxDrawableId);
        Bitmap close = BitmapFactory.decodeResource(getResources(), closeDrawableId);

        Bitmap bitmapCreate = Bitmap.createBitmap(box.getWidth(), box.getHeight(), Bitmap.Config.ARGB_8888);

        Canvas comboImage = new Canvas(bitmapCreate);

        comboImage.drawBitmap(box, 0, 0, null);
        comboImage.drawBitmap(close, box.getWidth()-close.getWidth(), box.getHeight()-close.getHeight(), null);
        if (box != null) {
            try {
                box.recycle();
                close.recycle();
                box = null;
                close = null;
            } catch (Throwable e) {
            }
        }
        return bitmapCreate;
    }

呼び方は?

imgView.setImageBitmap(combineImages(R.drawable.box,R.drawable.close));

出力

ここに画像の説明を入力

于 2013-11-11T11:27:58.300 に答える
2

次のようにフレーム レイアウトを使用できます。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/box" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="78dp"
        android:layout_height="61dp"
        android:layout_gravity="top"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="150dp"
        android:src="@drawable/Remove" />

</FrameLayout>

このコードの出力は次のとおりです。 ここに画像の説明を入力

于 2013-11-11T11:20:31.880 に答える