Make PagerIndicator respect padding
This commit is contained in:
parent
fc68fe4b9c
commit
63222f38cc
|
@ -86,11 +86,12 @@ public class PagerIndicatorView extends View {
|
|||
}
|
||||
|
||||
private void drawCircle(Canvas canvas, int position, float frac) {
|
||||
float circleRadiusSmall = canvas.getHeight() * 0.26f;
|
||||
float circleRadiusBig = canvas.getHeight() * 0.35f;
|
||||
float availableHeight = canvas.getHeight() - getPaddingTop() - getPaddingBottom();
|
||||
float circleRadiusSmall = availableHeight * 0.26f;
|
||||
float circleRadiusBig = availableHeight * 0.35f;
|
||||
float circleRadiusDelta = (circleRadiusBig - circleRadiusSmall);
|
||||
float start = 0.5f * (canvas.getWidth() - numPages * 1.5f * canvas.getHeight());
|
||||
paint.setStrokeWidth(canvas.getHeight() * 0.3f);
|
||||
float start = 0.5f * (canvas.getWidth() - numPages * 1.5f * availableHeight);
|
||||
paint.setStrokeWidth(availableHeight * 0.3f);
|
||||
|
||||
if (position == disabledPage) {
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
|
@ -99,7 +100,7 @@ public class PagerIndicatorView extends View {
|
|||
}
|
||||
|
||||
paint.setColor((Integer) new ArgbEvaluator().evaluate(frac, circleColor, circleColorHighlight));
|
||||
canvas.drawCircle(start + (position * 1.5f + 0.75f) * canvas.getHeight(), 0.5f * canvas.getHeight(),
|
||||
canvas.drawCircle(start + (position * 1.5f + 0.75f) * availableHeight, 0.5f * availableHeight + getPaddingTop(),
|
||||
circleRadiusSmall + frac * circleRadiusDelta, paint);
|
||||
}
|
||||
}
|
|
@ -4,44 +4,35 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:background="@android:color/holo_red_dark">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/appBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:minHeight="?attr/actionBarSize"
|
||||
tools:background="@android:color/darker_gray"/>
|
||||
android:theme="?attr/actionBarTheme"
|
||||
android:layout_alignParentTop="true"
|
||||
android:id="@+id/toolbar"/>
|
||||
|
||||
<de.danoeh.antennapod.view.PagerIndicatorView
|
||||
android:id="@+id/page_indicator"
|
||||
android:layout_height="8dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_marginTop="-12dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@android:color/transparent" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
<de.danoeh.antennapod.view.PagerIndicatorView
|
||||
android:id="@+id/page_indicator"
|
||||
android:layout_height="16dp"
|
||||
android:layout_width="40dp"
|
||||
android:layout_marginTop="-12dp"
|
||||
android:padding="4dp"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
<androidx.viewpager.widget.ViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_above="@id/playtime_layout"
|
||||
android:layout_below="@id/appBar"
|
||||
android:layout_below="@id/toolbar"
|
||||
android:foreground="?android:windowContentOverlay"
|
||||
tools:background="@android:color/holo_orange_light"
|
||||
android:layout_marginBottom="12dp" />
|
||||
|
|
Loading…
Reference in New Issue