Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are multiple ways to achieve a tutorial-like overlay. Probably the easiest one is to use specially prepared <a href="http://developer.android.com/guide/topics/ui/dialogs.html" rel="noreferrer">Dialog</a> window with transparent background and without dim behind.</p> <h2>Using custom <code>Dialog</code> for tutorial overlay</h2> <p>First of all we have to prepare content for the <code>Dialog</code>. In this example there will be one <code>TextView</code> inside <code>RelativeLayout</code> which is the most useful layout here.</p> <p>Content of <code>info_overlay.xml</code> file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:background="@android:color/darker_gray" android:padding="3dp" android:text="TextView" android:textColor="@android:color/white" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Now, we can use this layout to create our <code>Dialog</code>:</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Dialog overlayInfo = new Dialog(MainActivity.this); // Making sure there's no title. overlayInfo.requestWindowFeature(Window.FEATURE_NO_TITLE); // Making dialog content transparent. overlayInfo.getWindow().setBackgroundDrawable( new ColorDrawable(Color.TRANSPARENT)); // Removing window dim normally visible when dialog are shown. overlayInfo.getWindow().clearFlags( WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Setting position of content, relative to window. WindowManager.LayoutParams params = overlayInfo.getWindow().getAttributes(); params.gravity = Gravity.TOP | Gravity.LEFT; params.x = 100; params.y = 20; // If user taps anywhere on the screen, dialog will be cancelled. overlayInfo.setCancelable(true); // Setting the content using prepared XML layout file. overlayInfo.setContentView(R.layout.info_overlay); overlayInfo.show(); } </code></pre> <h3>Result</h3> <p>Below is the screenshot of the above solution working. Note the <code>TextView</code> over <code>ActionBar</code>.</p> <p><img src="https://i.stack.imgur.com/08xlL.png" alt="enter image description here"></p> <h3>A few notes about solution</h3> <ul> <li>If you'll have a dedicated button to dismiss tutorial you can probably use <code>setCancelable(false)</code> to avoid accidental closing of tutorial.</li> <li>This solution works with any theme with any action bar solution (either OS-provided, <em>Android Support Library</em> or <em>ActionBar Sherlock</em>)</li> </ul> <h2>Other solutions/helpers</h2> <p>Take a look at <a href="https://github.com/Espiandev/ShowcaseView" rel="noreferrer">Showcase View library</a> as it focuses on creating tutorial-like screens in easy way. I'm not sure however that it can easily overlay actionbars.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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