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

Bad focus on certain device / screen #193

Open
Amealky opened this issue Jun 19, 2020 · 29 comments
Open

Bad focus on certain device / screen #193

Amealky opened this issue Jun 19, 2020 · 29 comments

Comments

@Amealky
Copy link

Amealky commented Jun 19, 2020

( Nice issue template btw ;) ) and sorry for having comment multiple issue I mean it's better that I open my own issue

Used FancyShowCaseView version

1.3.0

Screenshot if there is something wrong with ui

Capture d’écran 2020-06-19 à 12 59 06

How you show/hide FancyShowCaseView (in Activity or Fragment, in which method)

In init method i use the code below :

  init {
        initTutorial()
    }

  private fun initTutorial() {
        TutorialManager.explainXXX(
            context,
            MyView,
            "My text"
        )?.show()
    }

this work fine on PIXEL 3 emulator but I try a run into Nexus 4 API 27 emulator and the focus change only on this screen ( work fine in another screen )

Your layout.xml file if the focus is wrong

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/block"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

<com.yarolegovich.discretescrollview.DiscreteScrollView
            android:id="@+id/list"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

I try multiple thing like :

put the height view in match parent
set fitSystemWindow = true

But nothing work... if you can help me it will be very niice 😄

@faruktoptas
Copy link
Owner

Can you share the code that you show the FancyShowCaseView?

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

here it is :

FancyShowCaseView.Builder(activity)
            .focusOn(focus)
            .disableFocusAnimation()
            .enableAutoTextPosition()
            .titleSize(19, TypedValue.COMPLEX_UNIT_DIP)
            .title(text)
            .titleGravity(Gravity.BOTTOM)
            .focusShape(FocusShape.ROUNDED_RECTANGLE)
            .roundRectRadius(36)
            .build()

@faruktoptas
Copy link
Owner

Thanks @Happeal which view are you trying to focus? Can you also share the layout.xml file please?

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

ofc the view is the following

<com.yarolegovich.discretescrollview.DiscreteScrollView
            android:id="@+id/list"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent" />

on the xml I provide you in my first post
Thank you to try solving my problem 😄

@faruktoptas
Copy link
Owner

you welcome :)
I think the problem is that when you build FancyShowCaseView.Builder() the scrollview has no children views. You add views dynamically in to the scrollview otherwise it should be a 0 height view.
Can you try showing the showcase after a delay inside a list.postDelayed() method?

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

I will try this 😄 and I will return to you for the result but why this work well on another device and fail on the nexus 4 ?

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

Unfortunately the problem is the same with a Delayed ( I put it to 1000ms by range of 100 ) 😞

@faruktoptas
Copy link
Owner

  • How do you populate the scrollview?

  • And can you clone this repository and run the samples? If samples work well, there is a problem with the device or your implementation.

@faruktoptas
Copy link
Owner

  • Do you have actionbar/toolbar?
  • Can yoy also share your theme style?

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

Okay,

  • How I populate the scrollview :
view.list.adapter = adapter
        view.list.addOnItemChangedListener(this)
        view.list.scrollToPosition(0)
        view.list.setSlideOnFling(true)
        view.list.setItemTransitionTimeMillis(220)
        view.list.setSlideOnFlingThreshold(500)
        view.list.setItemTransformer(
            ScaleTransformer.Builder()
                .setMinScale(0.7f)
                .build()
        )
  • I will try it soon and return with the result 😄

  • Yes I have an actionbar : an android basic one
    Theme.AppCompat.Light.DarkActionBar

  • There is the theme style :

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

a basic one too 😛

Yeah I hesitate between my implementation and a device problem because on other screen with nexus 4 it work well sooo its very weird .. but like you say I will try the sample

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

the sample run well on the nexus 4

@faruktoptas
Copy link
Owner

Interesting.
Samples don't contain ConstraintLayout may be there is an edge case with ConstraintLayout. I have to test.
Can you try using RelativeLayout instead of ConstraitLayout?

@Amealky
Copy link
Author

Amealky commented Jun 19, 2020

Yep I will try :)

@Amealky
Copy link
Author

Amealky commented Jun 22, 2020

I'll try but still same problem , My others screen are also ConstraintLayout but it work well on them

@Amealky
Copy link
Author

Amealky commented Jun 22, 2020

The only diff is that view is construct bottom to Top not top to bottom

@faruktoptas
Copy link
Owner

Can you provide me a sample project? I need to debug it.

@Amealky
Copy link
Author

Amealky commented Jun 23, 2020

Unfortunately I can't for now 😞

@faruktoptas
Copy link
Owner

Ok. I can see that there is a map on the layout. But the layout.xml file that you shared doesn't contain the map or the bottom views. Can you share the full layout?
And which one is the expected behavior below, green or red?

Screen Shot 2020-06-23 at 15 58 16

@Amealky
Copy link
Author

Amealky commented Jun 23, 2020

Ofc the red rectangle is the one :) I can explain more the code here :

Here is the full view :

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true"
        android:clipToPadding="false">

    <FrameLayout
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/banner"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            tools:layout_height="100dp"
            android:animateLayoutChanges="true"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    <ImageView
            android:id="@+id/image"
            style="@style/customStyle"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="10dp"
            android:elevation="5dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/view"
           />

    <ImageView
            android:id="@+id/setting"
            style="@style/customStyle2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="10dp"
            android:elevation="5dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="@id/image"/>
    
    <ProgressBar
            android:id="@+id/bar"
            android:layout_width="15dp"
            android:layout_height="15dp"
            android:layout_marginTop="5dp"
            app:layout_constraintEnd_toEndOf="@id/setting"
            app:layout_constraintStart_toStartOf="@id/setting"
            app:layout_constraintTop_toBottomOf="@id/setting" />

    <Button
            android:id="@+id/ok"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="10dp"
            android:layout_marginBottom="10dp"
            android:focusableInTouchMode="false"
            app:layout_constraintBottom_toTopOf="@id/block"
            app:layout_constraintEnd_toEndOf="parent"/>

    <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/block"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            tools:layout_height="200dp"
            android:animateLayoutChanges="true"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent">

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

then in this code the constraintLayout block is inflated dynamically by the view I give you on my first post

@faruktoptas
Copy link
Owner

Thanks :) Dynamic inflation may cause this but I will debug it.

@Amealky
Copy link
Author

Amealky commented Jun 23, 2020

I change the constraint layout by a Linear btw ( the empty layout ) but same problem :/

@Amealky
Copy link
Author

Amealky commented Jun 26, 2020

Hi @faruktoptas did you succeed ? 😄

@faruktoptas
Copy link
Owner

Not yet :)
I need to reproduce the buggy behavior at first.

@Amealky
Copy link
Author

Amealky commented Jun 29, 2020

Okay let me know because I don't succeed to fix it 😞

@faruktoptas
Copy link
Owner

The process will be faster if you provide me a sample with the steps to reproduce the bug.

@Amealky
Copy link
Author

Amealky commented Jun 30, 2020

When I use the fitSystemWindow it may fix some trouble on little device but cause damage on bigger device :/

@Amealky
Copy link
Author

Amealky commented Jun 30, 2020

Okay I think there is a problem in your lib with constraint layout ... ( when we don't set bottom or top and the height is on wrap content ) the showcase can figure out the limit of the top and the limit of the bottom

@glureau-betclic
Copy link

glureau-betclic commented Jul 8, 2020

You have no vertical constraint at all?

@faruktoptas
Copy link
Owner

I get the position with view.getLocationInWindow method. There is also an adjust height equals to statusBar height.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants