Skip to content

Commit d5f8146

Browse files
author
Chris Banes
committed
Stop using Layout Weight and Instead set the Height manually
1 parent d0b3bfd commit d5f8146

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

library/src/com/handmark/pulltorefresh/library/PullToRefreshBase.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,23 @@ final void refreshLoadingViewsSize() {
691691
setPadding(pLeft, pTop, pRight, pBottom);
692692
}
693693

694+
final void refreshRefreshableViewSize(int width, int height) {
695+
// We need to set the Height of the Refreshable View to the same as
696+
// this layout
697+
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mRefreshableViewWrapper.getLayoutParams();
698+
699+
switch (getPullToRefreshScrollDirection()) {
700+
case HORIZONTAL:
701+
lp.width = width;
702+
break;
703+
case VERTICAL:
704+
default:
705+
lp.height = height;
706+
break;
707+
}
708+
mRefreshableViewWrapper.requestLayout();
709+
}
710+
694711
final void setState(State state, final boolean... params) {
695712
mState = state;
696713
if (DEBUG) {
@@ -902,6 +919,9 @@ protected final Parcelable onSaveInstanceState() {
902919

903920
@Override
904921
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
922+
// Update the Refreshable View layout
923+
refreshRefreshableViewSize(w, h);
924+
905925
// We need to update the header/footer when our size changes
906926
refreshLoadingViewsSize();
907927
}
@@ -999,17 +1019,8 @@ private void addRefreshableView(Context context, T refreshableView) {
9991019
mRefreshableViewWrapper.addView(refreshableView, ViewGroup.LayoutParams.MATCH_PARENT,
10001020
ViewGroup.LayoutParams.MATCH_PARENT);
10011021

1002-
switch (getPullToRefreshScrollDirection()) {
1003-
case HORIZONTAL:
1004-
addViewInternal(mRefreshableViewWrapper, new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT,
1005-
1.0f));
1006-
break;
1007-
case VERTICAL:
1008-
default:
1009-
addViewInternal(mRefreshableViewWrapper, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0,
1010-
1.0f));
1011-
break;
1012-
}
1022+
addViewInternal(mRefreshableViewWrapper, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
1023+
LayoutParams.MATCH_PARENT));
10131024
}
10141025

10151026
@SuppressWarnings("deprecation")

0 commit comments

Comments
 (0)