Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List item prompt not displayed correctly #109

Closed
ccrockatt opened this issue Apr 16, 2018 · 5 comments
Closed

List item prompt not displayed correctly #109

ccrockatt opened this issue Apr 16, 2018 · 5 comments

Comments

@ccrockatt
Copy link

Overview

As you can see the prompt location overlaps the list item and is also partly not visible

listitempromptpositionissue

For context, the screen looks like this without the prompt

listitemnormal

I've tried calling .setClipToView(listView) but then the only thing visible is the bottom of the prompt, it doesn't position it below the list item

listitempromptpositionissuewithcliptoview

Here is the layout captured using layout inspector

layoutinspector

Reproduction steps

Code

It includes a delay to ensure it shows up as another user pointed out.

 public void showTapClassPromptForWizard()	{
		final ListView listView = findViewById(android.R.id.list);

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				new MaterialTapTargetPrompt.Builder(ClassListActivity.this)
						.setPrimaryText("Next let\'s add some students to the class")
						.setAnimationInterpolator(new FastOutSlowInInterpolator())
						.setPromptBackground(new RectanglePromptBackground())
						.setPromptFocal(new RectanglePromptFocal())
						.setTarget(listView.getAdapter().getView(0, null, listView))
						.show();
			}
		}, 1000);
	}

Layout

  • Default list and a default list item
<android.support.design.widget.CoordinatorLayout
    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"
    android:id="@+id/coordinatorLayout">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:gravity="top"
        android:orientation="vertical"
        tools:context=".ClassListActivity" >

        <ListView
            android:id="@android:id/list"
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:gravity="top"
            tools:listitem="@android:layout/simple_list_item_2" >
        </ListView>

        <TextView
            android:id="@android:id/empty"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center_vertical|center_horizontal"
            android:text="@string/no_classes_in_schedule_add_one" />

    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>

Library Version number

  • 2.7.0

Operating system and device

  • Android 5.1.1 API 22, Nexus 4
  • Android 6.0 API 23, Nexus 5
@sjwall
Copy link
Owner

sjwall commented Apr 16, 2018

Thanks for the detailed report, it looks like the prompt thinks that the target views location is at x: 0 y: 0 on the screen
You could try targeting one of the 2 text views in the list item to see if that gives a different result.
new Handler().postDelayed is used to ensure that the prompt looks for the target view after it has been added to the view hierarchy, usually when the prompt is created when a activity/fragment is first displayed

I will see if I can replicate the issue in the sample app and come up with a complete working example for a list view, hopefully by the end of the week

@ccrockatt
Copy link
Author

Thanks for replying sjwall.

I tried targeting the second text view and the result is fairly similar

listitempromptpositionissuetargettext2
(Ignore the green colouring, that's unrelated to the library)

I haven't looked into converting everything to use Recycler Views instead of List Views, assuming it's possible do you recommend that I try to do that for better compatibility with your library or do you think it should work equally well with either approach?

@sjwall
Copy link
Owner

sjwall commented Apr 17, 2018

The library is intended to work with both, there is a recyclerview example here which might give you some pointer as to why it might not be working

It wouldn't say to convert everything just to get this to work

@sjwall
Copy link
Owner

sjwall commented Apr 22, 2018

I can replicate the issue when calling .setTarget(listView.getAdapter().getView(0, null, listView)) changing it to .setTarget(listView.getChildAt(0)) works as desired.

I will commit a full example to the sample app shortly

@ccrockatt
Copy link
Author

ccrockatt commented Apr 22, 2018 via email

sjwall added a commit that referenced this issue Apr 22, 2018
@sjwall sjwall closed this as completed May 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants