ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î

Coach mark View [Android]
7³â Àü
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.



"Coach mark" is "Help overlay" in UX talk :-)

coach_mark.xml is your coach mark layout

coach_mark_master_view is the id of the top most view (root) in coach_mark.xml

public void onCoachMark(){

    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.setContentView(R.layout.coach_mark);
    dialog.setCanceledOnTouchOutside(true);
    //for dismissing anywhere you touch
    View masterView = dialog.findViewById(R.id.coach_mark_master_view);
    masterView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
    dialog.show();
}
Adding sample of coach_mark.xml (to this excellent solution given by Oded Breiner), so its easy for ppl to copy & paste to see working example quickly.

Sample of coach_mark.xml here, change the -> drawable/coach_marks to your image:

coach_mark.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/coach_mark_master_view">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
         <ImageView
             android:id="@+id/coach_marks_image"
             android:layout_width="match_parent"
             android:layout_height="match_parent"
             android:layout_centerInParent="true"
             android:layout_gravity="center_horizontal"
             android:src="@drawable/coach_marks" />
    </RelativeLayout>
</LinearLayout>
And optionally use this theme to remove padding:

<style name="WalkthroughTheme" parent="Theme.AppCompat">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>
ÃßõÃßõ : 225 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
1,196
Service & Notification(¾Ë¸²¹Ù¶ç¿ì±â) ÀÌ¿ëÇϱâ
1,195
È­¸é ȸÀü(rotation) ó¸®
1,194
[Android] Àüüȭ¸é, title bar ¾ø¾Ö±â, status bar ¾ø¾Ö±â
1,193
ANDROID(¾Èµå·ÎÀ̵å) ¾Û °³¹ß ±âÃÊ] MEDIAPLAYER À½¾Ç Àç»ýÇϱâ
1,192
[Android]MediaPlayer¿¡¼­ »ç¿îµå¸¦ Àç»ýÇÏ´Â µÎ °¡Áö °æ·Î
1,191
¾Èµå·ÎÀ̵å Intent »ç¿ë¹ý
1,190
¾Èµå·ÎÀ̵å È­¸é Á¤¸®
1,189
ffmpeg ¿ÀÇ ¼Ò½º on ¾Èµå·ÎÀ̵å
1,188
WebView¿¡¼­ <a> ű×ÀÇ "_blank" target ó¸®Çϱâ.
1,187
Ư¼ö¹®ÀÚ, Ư¼ö¹®ÀÚÇ¥, Ư¼ö¹®ÀÚ ÇÏÆ®, ¿¹»Û Ư¼ö¹®ÀÚ
1,186
MediaPlayer 5¹ø¸¸ ¹Ýº¹Àç»ý
1,185
ÆÄÀÏ À§Ä¡¿¡ µû¸¥ ¹Ìµð¾î Àç»ý »ùÇÃÄÚµå
1,184
MJPEG on Android anyone?
1,183
Android °³¹ß
1,182
¾Èµå·ÎÀ̵å : ¾×ƼºñƼ ¶óÀÌÇÁ »çÀÌŬ (Activity Life Cycle)
1,181
¾Èµå·ÎÀ̵å ÇÁ·Î±×·¥ ÄÚµå·Î À¥ ºê¶ó¿ìÀú ½ÇÇàÇϱ⠿¹Á¦ (ÀÎÅÙÆ® »ç¿ë)
1,180
Áøµ¿ È¿°ú [Android]
1,179
Á¾·á ´ÙÀ̾ó·Î±× [Android]
1,178
´Ù¸¥¾Û È£Ãâ [Android]
1,177
TabActivity back key Event [Android]
1,176
³×Æ®¿öÅ© »óÅ [Android]
1,175
¾Èµå·ÎÀ̵忡¼­ À¥¼­¹ö¿¡ post·Î ±Û¾²±â [Android]
1,174
Webview ¼Ò½º [Android]
Coach mark View [Android]
1,172
¸ÖƼ ÇØ»óµµ [Android]
1,171
Webview source [Android]
1,170
°øÀ¯ Intent [Android]
1,169
intent uri ¸ðÀ½ [Android]
1,168
http post [Android]
1,167
http ¿äû [Android]
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.