teekib
teekib

Reputation: 2821

Android: How to obtain an overlay on top of acitivity

when my application is installed for the first time by the user , i want to explain him what each activity does (like a quick tip) , it should look like the below picture

enter image description here

it should have the cancel button , and should not repeat after the first install,

I need suggestion or any useful links ,how to implement it, Any help is appreciated.

Upvotes: 2

Views: 265

Answers (1)

wayne_bai
wayne_bai

Reputation: 1228

You could use SharePreference to store the state whether or not user have viewed your instruction. Just add a boolean value named as 'instructionViewed' to SharePreference. Every time your application launched, check the value. If true, don't show instruction. If false, show instruction. When user click the cancel button, set the value to true.

SharePreference is a very easy-using class to help store some information.You could google how use it.

Hope this helpful.


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

         //Check SharePreference
         boolean instructionViewed = checkInstrunctionState();

         //If the instruction is not viewed, show instruction.    
         if(!instructionViewed){
               RelativeLayout yourLayout = createYourOwnUi();
               FrameLayout contentView  = (FrameLayout)(getWindow().getDecorView().findViewById(android.R.id.content));
               FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(MATCH_PARENT,MATCH_PARENT);
               contentView.addView(yourLayout, lp);
             }
        }

Upvotes: 1

Related Questions