Android image view resizing with scroll offset
<p>So I'm having trouble with resizing an Imageview dynamically. I'm working with the Spotify SDK and for the album art I want the image to resize according to the bottom sheet scroll offset.</p>

<p>First of all, I can only post 1 link so <a href="https://photos.google.com/share/AF1QipNJMISP9SiABtXrtM3l7nbx2Ren4p8DO7_gww7FydJj-rZjJ90Pg1nf0yYjlHIyVw?key=bXZhSWp0NndxbkREUnNCVzhvaWVub1dVZ1dqdzBR" rel="nofollow">here's an album with screenshots</a></p>

<p>So the image on the bottom left (first image in link) should resize to the second image in the link. It's a simple imageview in the bottom sheet (frame layout), this is my code: </p>

<pre><code>   mBottomSheetBehaviour.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            int state = newState == BottomSheetBehavior.STATE_EXPANDED ? View.VISIBLE : View.GONE;
            mCloseSheetButton.setVisibility( state );
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            // Animate fab
            int width = bottomSheet.getWidth();
            int translationX = (int) ((-width / 2f + mFAB.getWidth() / 2f + dpToPx(16) ) * slideOffset);
            mFAB.setTranslationX(translationX);

            float imgWidth = Math.max(getResources().getDimension(R.dimen.abc_action_bar_default_height_material), width * slideOffset);
            Log.e("test", "onSlide: max " + imgWidth);
            Log.e("test", "onSlide: img" + String.valueOf(mAlbumArt.getLayoutParams().height));
            mAlbumArt.getLayoutParams().height = (int) (imgWidth);
            mAlbumArt.getLayoutParams().width = (int) (imgWidth);
            mAlbumArt.requestLayout();
            // tried this, but does nothing: mAlbumArt.invalidate();
        }
    });
</code></pre>

<p>I can see the Logs and they say that the size is changing, but the image stays small (third image). The weirdest thing, is that when I press play/pause the image does resize (only when the bottom sheet is fully extended or not extended at all, can't do that when scrolling). The play/pause is handled by the SDK and I only call this function:</p>

<pre><code> private void updateButtons() {
    boolean loggedIn = isLoggedIn();

    mFAB.setImageResource(mYfitopsHelper.isPlaying() ? android.R.drawable.ic_media_pause : android.R.drawable.ic_media_play);

    // Login button should be the inverse of the logged in state
    Button loginButton = (Button) findViewById(R.id.login_button);
    loginButton.setText(loggedIn ? R.string.logout_button_label : R.string.login_button_label);

    // Set enabled for all widgets which depend on initialized state
    for (int id : REQUIRES_INITIALIZED_STATE) {
        findViewById(id).setEnabled(loggedIn);
    }

    // Same goes for the playing state
    boolean playing = loggedIn &amp;&amp; mYfitopsHelper.mCurrentPlayerState.trackUri != null;
    for (int id : REQUIRES_PLAYING_STATE) {
        findViewById(id).setEnabled(playing);
    }
}
</code></pre>

<p>I don't understand why the Imageview is only updated when one of the buttons in pressed... Any suggestions?</p>