Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You mean a fullscreen camera preview?</p> <p>I use this code:</p> <pre><code>this.requestWindowFeature(Window.FEATURE_NO_TITLE); //no title getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //no status bar, etc </code></pre> <p>and this:</p> <pre><code>setContentView(R.layout.main); addContentView(overlay, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); ((FrameLayout) findViewById(R.id.preview)).addView(preview); </code></pre> <p>the first snippet sets the app to fullscreen and hide title and status bar. the second snipppet adds my overlay (extended View) to the main layout.</p> <p>Here my xml and java code: main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;FrameLayout android:id="@+id/preview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Overlay.java:</p> <pre><code>class Overlay extends View { String text = ""; String textBearing = "Bearing: "; public Overlay(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); paint.setTextSize(16); canvas.drawText(text, 20, 20, paint); canvas.drawText(textBearing, 20, 50, paint); super.onDraw(canvas); } } </code></pre> <p>And my activity:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); //no title getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //fullscreen overlay = new Overlay(this); setContentView(R.layout.main); addContentView(overlay, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); camera = getCameraInstance(); //camera.open(); preview = new Preview(this, camera); ((FrameLayout) findViewById(R.id.preview)).addView(preview); } </code></pre> <p>Hope it helps</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload