Skip to content

Commit

Permalink
Don't check for MeasureSpec.EXACTLY width because RelativeLayout may …
Browse files Browse the repository at this point in the history
…call onMeasure with intermediate EXACTLY spec.
  • Loading branch information
Nikita Olifer committed Feb 22, 2018
1 parent b3a9a5f commit e46ab84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ implementation "com.android.support:appcompat-v7:x.x.x"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
```
There is no possibility to set fixed indicator width (because it's width is based on ```spi_visibleDotCount```).

3. Attach indicator to ViewPager:
```java
ViewPager pager = findViewById(R.id.pager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,11 @@ public void setCurrentPosition(int position) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Width
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
if (widthMode == MeasureSpec.EXACTLY) {
throw new IllegalStateException("Fixed width is not supported");
}
int measuredWidth;
// We ignore widthMeasureSpec because width is based on visibleDotCount
if (isInEditMode()) {
measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
// Maximum width with all dots visible
measuredWidth = (visibleDotCount - 1) * spaceBetweenDotCenters + dotSelectedSize;
} else {
measuredWidth = dotCount >= visibleDotCount
? (int) visibleFrameWidth
Expand Down

0 comments on commit e46ab84

Please sign in to comment.