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

FillParent and MatchParent awareness for content in scrollview #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

if (mScrollView != null)
{
measureChild(mScrollView, MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec),
MeasureSpec.AT_MOST));
measureChildren(widthMeasureSpec, heightMeasureSpec);

mScrollContentHeight = mScrollView.getChildAt(0).getMeasuredHeight();
mScrollViewHeight = mScrollView.getMeasuredHeight();
Expand Down Expand Up @@ -218,9 +215,11 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
{
final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mScrollView
.getLayoutParams();

final int width = mScrollView.getMeasuredWidth();
final int height = mScrollView.getMeasuredHeight();

@SuppressWarnings("deprecation")
final int width = (lp.width==LayoutParams.MATCH_PARENT||lp.width==LayoutParams.FILL_PARENT)?this.getWidth():mScrollView.getMeasuredWidth();
@SuppressWarnings("deprecation")
final int height = (lp.height==LayoutParams.MATCH_PARENT||lp.height==LayoutParams.FILL_PARENT)?this.getHeight():mScrollView.getMeasuredHeight();

int childLeft;
int childTop;
Expand Down Expand Up @@ -265,14 +264,13 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
default:
childTop = parentTop + lp.topMargin;
}

mScrollView.layout(childLeft, childTop, childLeft + width, childTop + height);

}

if (mBackground != null)
{
final int scrollYCenterOffset = -mScrollView.getScrollY();
final int scrollYCenterOffset = mScrollView.getScrollY();
final int offset = (int) (scrollYCenterOffset * mScrollDiff);
// Log.d(TAG, "Layout Scroll Y: " + scrollYCenterOffset +
// " ScrollDiff: " + mScrollDiff
Expand Down