Android设置全屏,画图,加载位图-成都快上网建站

Android设置全屏,画图,加载位图

设置全屏: activity中

专注于为中小企业提供成都网站制作、网站设计、外贸网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业西乡免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
                   

加载位图:

Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.chessboard);

实例:

public class GameActivity extends Activity {
    public class MyView extends View
    {
        public MyView(Context context) {
            super(context);
        }
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.chessboard);
            int width = canvas.getWidth();
            int height = canvas.getHeight();
            Paint paint = new Paint();
            paint.setColor(Color.RED);
            canvas.drawLine(0, 0, width - 1, height - 1, paint);
            Rect rect1 = new Rect(0, 0, canvas.getWidth(), canvas.getHeight());
            Rect rect2 = new Rect(0, 0, map.getWidth() / 2, map.getHeight() / 2);
            canvas.drawBitmap(map, rect2, rect1, null);
            invalidate();
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //设置全屏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
          
//      setContentView(R.layout.activity_game);
        setContentView(new MyView(this));
    }

文章标题:Android设置全屏,画图,加载位图
文章出自:http://kswjz.com/article/pdesop.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流