How to Create a Help Overlay Like You See in a Few Android Apps and Ics

How do I create a help overlay like you see in a few Android apps and ICS?

Let's assume you ordinarily would call setContentView(R.layout.main), but on first run, you want to have this overlay.

Step #1: Create a FrameLayout in Java code and pass that to setContentView().

Step #2: Use LayoutInflater to inflate R.layout.main into the FrameLayout.

Step #3: Use LayoutInflater to inflate the overlay into the FrameLayout.

Step #4: When the user taps the button (or whatever) to dismiss the overlay, call removeView() to remove the overlay from the FrameLayout.

Since the overlay is a later child of the FrameLayout, it will float over top of the contents of R.layout.main.

how to create a helper screen in android

I have done some modifications in your code.

Here is the activity_main.xml look's like

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="eflair.helperscreentutorial.MainActivity">

<Button
android:id="@+id/newButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="New Button" />

<FrameLayout
android:id="@+id/fullScreenLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

Here is the MainActivity.java look's like

public class MainActivity extends AppCompatActivity {

private FrameLayout fullScreenLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

fullScreenLayout = (FrameLayout) findViewById(R.id.fullScreenLayout);

final RelativeLayout layout = new RelativeLayout(this); // Dynamically creating layout
layout.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams
.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
layout.setBackgroundColor(Color.DKGRAY); // Setting bgcolor to the layout
layout.setAlpha(0.5f); // Setting opacity to the layout
layout.setBackgroundResource(R.drawable.helperscreen); // Adding image to layout
layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fullScreenLayout.removeView(layout); // On clicking the image layout will be removed
}
});
fullScreenLayout.addView(layout); // Adding view to the layout

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.cb:
Toast.makeText(getApplicationContext(), "Text Copied", Toast.LENGTH_LONG).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}

You need to create image like this, that i'm using in this example.
Sample Image

And here is the output.

Sample Image

How to create an info overlay in Android

I think that this library : ShowcaseView is your best option.
As its name implies, it allows you to recreate the Android 4.x showcase view; ie :

Showcase view sample.

The documentation of the project explains how to implement it.
Word of advice though : this kind of explanation view is viewed as bad design most of the time : if your application is well designed, you don't need to provide a tutorial to the user, it is supposed to be intuitive.

It can be totally justified in some cases of course, just be sure that :

-your users really need a tutorial.

-it is not because you are doing something opposite to the Android convetions.

TYPE_SYSTEM_OVERLAY in ICS

Everything you describe is true. It is presumably to tighten up security, as the former behavior was the source of tapjacking attacks. I wrote a blog post recently about this change.

Any idea's?

Don't use either of them.

How make an Overlay who only detect gesture. Android 4.x

Let's assume you ordinarily would call setContentView(R.layout.main), but on first run, you want to have this overlay.

Step #1: Create a FrameLayout in Java code and pass that to setContentView().

Step #2: Use LayoutInflater to inflate R.layout.main into the FrameLayout.

Step #3: Use LayoutInflater to inflate the overlay into the FrameLayout.

Step #4: When the user taps the button (or whatever) to dismiss the overlay, call removeView() to remove the overlay from the FrameLayout.

Since the overlay is a later child of the FrameLayout, it will float over top of the contents of `R.layout.main



Related Topics



Leave a reply



Submit