0

静止画像に画像を挿入しようとしています(フレーム内の画像のようなもの)。ある程度は取れましたが、与えられた画像にうまく収めることができませんでした。

オレンジ色の境界線は、マップ内のマーカーに動的に挿入する必要があるフレームとプレースホルダーです。

ここに画像の説明を入力

これが私が試したことです:

    Bitmap pic = BitmapFactory.decodeResource(getResources(),
            R.drawable.bluepic);
    Bitmap orangeframe = BitmapFactory.decodeResource(getResources(),R.drawable.orangeborder);
    Bitmap out = combineImages(orangeframe, pic);

   public Bitmap combineImages(Bitmap frame, Bitmap image) 
   {

    Bitmap cs = null;
    Bitmap rs = null;

    rs = Bitmap.createScaledBitmap(frame, image.getWidth(),
            image.getHeight(), true);

    cs = Bitmap.createBitmap(rs.getWidth(), rs.getHeight(),
            Bitmap.Config.RGB_565);

    Canvas comboImage = new Canvas(cs);

    comboImage.drawBitmap(image,0, 0, null);
    comboImage.drawBitmap(rs, 0, 0, null);

    if (rs != null) {
        rs.recycle();
        rs = null;
    }
    Runtime.getRuntime().gc();

    return cs;
}

私はこれを取得しています:

ここに画像の説明を入力

プレースホルダーは動的で、オレンジ色のフレーム イメージは静的です。プログラムでオレンジ色の画像の中に画像を直接挿入したいと思います。

これは可能ですか?

4

2 に答える 2

0

そのために9パッチを使用できます。
http://developer.android.com/tools/help/draw9patch.html

オレンジ色の画像で制限を定義するだけです。

そして、次のように階層を構築します。

<FrameLayout 
    background="static 9patch image" >
   <ImageView
       src="dynamic image"/>
</FrameLayout>
于 2014-09-19T13:10:58.500 に答える
0

オレンジ枠はイメージビューですよね?次のように、別の画像ビューをその上に重ねることができます。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/map_marker"/>


<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="8dp"
    android:layout_gravity="center"
    android:background="@drawable/my_placeholder"/>


</FrameLayout>
于 2014-09-19T13:02:59.343 に答える