标签:
@authur : qingdujun 2015年4月15日21:00:03
MainActivity.java中设置全屏,注意:其设置必须在setContentView之前;
package com.qdj.gameone; import com.qdj.ui.ViewOne; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Note that some flags must be set before the window decoration is created. */ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); /* Flag for the "no title" feature, turning off the title at the top of the screen. */ requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(new ViewOne(this)); } } /** * 中文(Chinese): * getWindow().setFlags() ——用于去除界面最上面的电池显示部分; * requestWindowFeature() ——是用于去除标题栏(并不是最上面的电池部分); */
自定义View
package com.qdj.ui; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.View; public class ViewOne extends View { private Paint paint = null; public ViewOne(Context context) { super(context); paint = new Paint(); /*setting or clearing the ANTI_ALIAS_FLAG bit * AntiAliasing smooths out the edges of what is being drawn.*/ paint.setAntiAlias(true); /*Controls whether the screen should remain on.*/ setKeepScreenOn(true); paint.setColor(Color.RED); } @Override public void onDraw(Canvas canvas) { /* set background color. */ canvas.drawColor(Color.BLACK); canvas.drawText("Android Game Develop", 30, 30, paint); } }
标签:
原文地址:http://www.cnblogs.com/qingdujun/p/4430186.html