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

Image is not displayed initially #7

Closed
francophong opened this issue Aug 28, 2014 · 1 comment
Closed

Image is not displayed initially #7

francophong opened this issue Aug 28, 2014 · 1 comment

Comments

@francophong
Copy link

Hi,

I edited the layout a bit for my project's purpose as below:

    <com.flavienlaurent.notboringactionbar.KenBurnsView
        android:id="@+id/header_picture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/picture0" />

// I replace the imageview with a custom view

        <ImageView
            android:id="@+id/header_logo"
            android:layout_width="@dimen/header_logo_size"
            android:layout_height="@dimen/header_logo_size"
            android:layout_centerInParent="true"
            android:layout_alignParentTop="true"
            android:paddingTop="15dp"
            />

        <ImageView
            android:id="@+id/header_logo_hide"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_centerHorizontal="true" />

        <TextView
            android:id="@+id/header_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/header_logo"
            android:layout_centerHorizontal="true
            android:paddingTop="20dp"
            android:textSize="20dp"
            android:textStyle="bold" />
  </RelativeLayout>

</FrameLayout>

and I use this layout in a fragment, so the code was changed a bit to work in fragment

  • The view was inflated in onCreateView and onActivityCreated.
  • Instead of interpolating header_logo to the action bar icon, I want header_logo to interpolating to the header_logo_hide. The code changed:
    interpolate(mHeaderLogo, mHeaderLogoHide, sSmoothInterpolator.getInterpolation(ratio));

Issue: when open the fragment, the header_logo is not displayed unless I make a initial action like scroll or touch or click.

Please help to advise me.

@francophong
Copy link
Author

I debugged and found the issue.
The calculation of ScaleX and ScaleY return "NaN" by somehow.
Solution: change the calculation
float scaleX = 1.0F + interpolation * (mRect2.width() /360.0F - 1.0F);
It worked as a charm

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

1 participant