重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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://cqcxhl.com/article/pdesop.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP