SwipeRevealLayout icon indicating copy to clipboard operation
SwipeRevealLayout copied to clipboard

Improper ListView row while changing orientation from Landscape to Portrait & vice-versa

Open lalit3686 opened this issue 8 years ago • 11 comments

Hi,

I observed that when you change orientation from Portrait to Landscape the ListView row sticks to the same width giving improper size of ListView row. Also, same is the case with changing orientation from Landscape to Portrait.

I am using

android:configChanges="orientation|keyboardHidden|screenSize"

in AndroidManifest.xml

Please provide the fix!

Thanks!

lalit3686 avatar Dec 30 '16 09:12 lalit3686

I found the issue to be caused by PR https://github.com/chthai64/SwipeRevealLayout/pull/33. If i skip the "width" calculation from this PR it works ok.

draghia-andrei avatar Jan 10 '17 21:01 draghia-andrei

I tried to comment out

widthMeasureSpec = MeasureSpec.makeMeasureSpec(desiredWidth, widthMode);

But, it didn't work for me, it just centers the row, but doesn't full-screen its width

lalit3686 avatar Jan 11 '17 06:01 lalit3686

I commented desiredWidth = Math.max(child.getMeasuredWidth(), desiredWidth); as well.

Also, I don't have android:configChanges="orientation|keyboardHidden|screenSize" so my Activity is destroyed and re-created. There was an older issue about this and it is not implemented out of the box to handle configurationChange so you would probably need to do it yourself.

draghia-andrei avatar Jan 11 '17 09:01 draghia-andrei

If I don't comment anything & re-create the Activity again its already working fine, then why would I post the issue? Feels sick that you didn't look at my question properly!

lalit3686 avatar Jan 11 '17 09:01 lalit3686

Leaving asside your rude language, you would post this issue if you had the problem from this issue, even when re-creating the activity...

If this doesn't help you, maybe it will help someome else.

draghia-andrei avatar Jan 11 '17 20:01 draghia-andrei

Ok, great! keep writing useless libraries & also don't dare to solve the bugs! Best of Luck & Get Well Soon!

lalit3686 avatar Jan 12 '17 04:01 lalit3686

Erm...I hope you know I am not the one that wrote this library or even contributed to it. I am just someone who uses it for a project. If you look at the activity on this library, you are better off debugging the issue yourself, like I did for my issue.

draghia-andrei avatar Jan 12 '17 19:01 draghia-andrei

I have save issue with recyclerview. android:configChanges not work. Anyone have solution to resolve this issue.

MukFlex avatar Apr 04 '17 06:04 MukFlex

Any help with the issue. It exists still

JyotiDubey avatar Jul 12 '17 13:07 JyotiDubey

If this problem is actual in 2018, here's the solution

private void changeLayout() {
           int pageWidth = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
           RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
           params.width = pageWidth;
           mBinding.swipeLayout.setLayoutParams(params);
       }

where should i put that

vegapunk1209 avatar Oct 15 '18 01:10 vegapunk1209

The problem is that the children loose there layoutparams when created. So just make sure to reset your child layoutparams.

  // first find the largest child
        for (int i = 0; i < getChildCount(); i++) {
            View child = getChildAt(i);
            if(i == 1){
                child.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
            }
            child.invalidate();
            measureChild(child, widthMeasureSpec, heightMeasureSpec);
            desiredWidth = Math.max(child.getMeasuredWidth(), desiredWidth);
            desiredHeight = Math.max(child.getMeasuredHeight(), desiredHeight);
        }

gisman82 avatar Nov 29 '18 08:11 gisman82