从sd卡在android中以45度角将图像添加到帧中

从sd卡在android中以45度角将图像添加到帧中,android,Android,上面的图片是您可以看到的白色部分,我需要将图像包含到SD卡的该部分中。我需要的是,SD卡的图像应适合屏幕中的空白区域(图像应旋转45度)。如何包含图像?有一个示例: 为了使图像居中,我会使用相对布局(我没有测试过这段代码,但我认为它应该可以工作): 如何使图像位于屏幕中央sam也请回答此问题谢谢,我已使用相对布局更新了我的答案。那么,你接受吗? import android.app.Activity; import android.graphics.Bitmap; import android.

上面的图片是您可以看到的白色部分,我需要将图像包含到SD卡的该部分中。我需要的是,SD卡的图像应适合屏幕中的空白区域(图像应旋转45度)。如何包含图像?

有一个示例:

为了使图像居中,我会使用相对布局(我没有测试过这段代码,但我认为它应该可以工作):


如何使图像位于屏幕中央sam也请回答此问题谢谢,我已使用相对布局更新了我的答案。那么,你接受吗?
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.widget.ImageView;

public class TestImages extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ImageView image = (ImageView) findViewById(R.id.test_image);
        Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.test);
        Matrix mat = new Matrix();
        mat.postRotate(45);
        Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(),bMap.getHeight(), mat, true);
        image.setImageBitmap(bMapRotate);
    }
}
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,  RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
image.setLayoutParams(params);