-
Notifications
You must be signed in to change notification settings - Fork 318
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
[BUG] All the curves and radius elements are squared in Android 9.0 #23
Comments
This is due to the intended behavioral changes of Path drawings and how the system handles the drawing of XFerModes paints in Android Pie. I have managed to create a temporary solution for Android Pie. First create a class that extends ViewOutlineProvider: import android.annotation.TargetApi;
import android.graphics.Outline;
import android.os.Build;
import android.view.View;
import android.view.ViewOutlineProvider;
@TargetApi(Build.VERSION_CODES.P)
public class ProgressOutlineProvider extends ViewOutlineProvider{
private float radius = -1;
@Override
public void getOutline(View view, Outline outline) {
if(radius != -1) {
outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), radius);
}
}
public void updateProgress(float maxRadius, float progress) {
this.radius = maxRadius - maxRadius * (1 - progress);
}
} Then modify the onCreate method of your activity: public class CollapsingDemoActivity extends AppCompatActivity {
private ProgressOutlineProvider pop;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collapsing);
final ScalingLayout sl = findViewById(R.id.scalingLayout);
sl.setListener(new ScalingLayoutListener() {
@Override
public void onCollapsed() {}
@Override
public void onExpanded() {}
@Override
public void onProgress(float progress) {
if(pop != null) { pop.updateProgress(sl.getSettings().getMaxRadius(), progress); }
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
pop = new ProgressOutlineProvider();
sl.setOutlineProvider(pop);
sl.setClipToOutline(true);
sl.post(new Runnable() {
@TargetApi(Build.VERSION_CODES.P)
@Override
public void run() {
pop.updateProgress(sl.getSettings().getMaxRadius(), 1);
sl.invalidateOutline();
}
});
}
}
} Works flawlessly for now |
@Camerash where to make the changes in the library .... can anyone provide the guide? |
No description provided.
The text was updated successfully, but these errors were encountered: