2
我在應用程序中有一個簡單的VectorDrawable。它來自Android SDK和看起來像這樣:繪製VectorDrawable在不同的尺寸
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
</vector>
我想把它畫成400×400位,使得其擴展到填充位圖。目前,當我繪製它時,它只在24x24顯示。這裏的代碼:
ImageView imageview = (ImageView) findViewById(R.id.image_view);
VectorDrawable drawable = (VectorDrawable) getResources().getDrawable(
R.drawable.testvector, null);
// drawable.mutate();
int width = 400
int height = 400;
Bitmap mutableImage = Bitmap.createBitmap(
metrics, width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(mutableImage);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
imageview.setImageDrawable(drawable);
你在'metrics'中有什麼?當我離開它時,你想要的東西適合我。 – Anthony