Poya.B4A
Member
Hi there;
I'm trying to round Custom Corner of some view's but just change the buttom background view, TNX for any replay.
JavaCode Sub ?
I'm trying to round Custom Corner of some view's but just change the buttom background view, TNX for any replay.
B4X:
Sub Button1_Click
Dim sizee As Int = SeekBar1.Value
Panel1.Invalidate 'I put this code befor and after the next line but no change
Custom_RoundCorners(Panel1,sizee,sizee,0,0)
Panel1.Invalidate
Custom_RoundCorners(Button1,sizee,sizee,0,0)
Custom_RoundCorners(ImageView1,sizee,sizee,0,0)
ImageView1.Invalidate
End Sub
JavaCode Sub ?
B4X:
Sub Custom_RoundCorners(View As View, topLeftRadius As Float, topRightRadius As Float,bottomRightRadius As Float, bottomLeftRadius As Float)
#If java
import android.graphics.Outline;
import android.graphics.Path;
import android.view.View;
import android.view.ViewOutlineProvider;
public void roundCustomCorners(View view, float topLeftRadius, float topRightRadius, float bottomRightRadius, float bottomLeftRadius) {
view.setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
Path path = new Path();
path.addRoundRect(0, 0, view.getWidth(), view.getHeight(), new float[] {topLeftRadius, topLeftRadius, topRightRadius, topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius}, Path.Direction.CW);
outline.setConvexPath(path);
}
});
view.setClipToOutline(true);
}
#End If
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("roundCustomCorners",Array(View,topLeftRadius,topRightRadius,bottomRightRadius,bottomLeftRadius))
Log("Success...")
End Sub
Attachments
Last edited: