开发者

How do I add a graphic overlay on an activity? Android

I am trying to have a picture show up in the middle of the screen guiding people what to press (eg an arrow to a button). What do I use so that the arrow design will show up at the appropriate spot and dissapear after I do something (like press the screen)

Thanks!

EDIT Here is the xml layout for one of my activities, note the imageview at the bottom, it shows the picture in the front

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout android:layout_width="fill_parent"
    android:layout_height="45dp" android:background="@drawable/mytitlebackground" android:id="@+id/relativeLayout1">
    <ImageButton android:id="@+id/btnAddFriends"
        android:layout_width="wrap_content" android:src="@android:drawable/ic_input_add"
        android:layout_height="wrap_content" android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"></ImageButton>
    <TextView android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="@string/imTracking" android:textAppearance="?android:attr/textApp开发者_Python百科earanceLarge" android:layout_centerVertical="true" android:layout_centerHorizontal="true"></TextView>
</RelativeLayout>

<Button android:id="@+id/btnUpdateLocation" android:text="Update Location"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"></Button>
<ImageButton android:src="@drawable/mapbutton"
    android:layout_width="wrap_content" android:id="@+id/btnMaps"
    android:layout_height="wrap_content" android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true" android:layout_alignTop="@+id/btnUpdateLocation"></ImageButton>
<ImageButton android:text="Refresh"
    android:src="@android:drawable/stat_notify_sync" android:layout_width="wrap_content"
    android:id="@+id/btnRefresh" android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"></ImageButton>
<LinearLayout android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:layout_below="@+id/relativeLayout1"
    android:layout_alignParentLeft="true" android:layout_above="@+id/btnUpdateLocation" android:id="@+id/linearLayout1">
    <ListView android:id="@+id/imtrackinglistview"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:layout_weight="1"></ListView>
</LinearLayout>
<ImageView android:id="@+id/iVImtrackingpopup" android:layout_width="300dp" android:layout_height="330dp" android:src="@drawable/imtrackinghelp_en" android:layout_centerVertical="true" android:layout_centerHorizontal="true"></ImageView>

When I try to "click" the relative layout to make the image invisible, it doesn't work unless I click the top of the layout

RelativeLayout Imtrackingrelativelayout=(RelativeLayout) findViewById(R.id.relativeLayoutImtracking);
    Imtrackingrelativelayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ImageView imtrackingoverlay=(ImageView) findViewById(R.id.iVImtrackingpopup);
            imtrackingoverlay.setVisibility(View.INVISIBLE);

        }
    });


make the image centre aligned and put click listener over root layout and on click make this image invisible......Better to use relative layout for this.....


Have you tried using the ShowcaseView library? It offers a more cleaner approach to what you are trying to achieve

Check out the project here:-

https://github.com/amlcurran/ShowcaseView

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜