Hi I am trying to reduce the circle background of a selected date. The gray circle of the date selected by default is getting too big, can i decrease the circle size of the selected day?
Any help would be appreciated ThankYou
You can try to use the shape attribute to control the shape you want.
I've tried it before. Still the same issue and basically the background flickers as the calendar is opened and when i select any other date the same happens.
this is mine my_selector.xml code:
<item android:state_checked="true"
android:drawable="@drawable/shape_selection_bg" />
<item android:state_pressed="true"
android:drawable="@drawable/shape_selection_bg" />
<item android:drawable="@android:color/transparent" />
shape_selection_bg.xml :
<corners android:radius="2dp" />
<solid android:color="@color/c_1495eb" />
<stroke
android:width="1dp"
android:color="@android:color/transparent" />
Thank You @lvfaqiang for your time but it didn't solve my problem .
666
private void calculateBounds(int width, int height) {
final int radius = Math.min(height, width)/2;
final int xoffset =Math.abs(width-radius)/2;
final int yoffset =Math.abs(height-radius)/2;
// Lollipop platform bug. Circle drawable offset needs to be half of normal offset
final int xcircleOffset = Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP ? xoffset / 2 : xoffset;
final int ycircleOffset = Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP ? yoffset / 2 : yoffset;
Logger log = Logger.getLogger("lavasoft");
if (width >= height) {
circleDrawableRect.set(xoffset, yoffset, radius + xoffset, radius+yoffset);
circleDrawableRect.set(xcircleOffset, ycircleOffset, radius + xcircleOffset, radius+ycircleOffset);
}
}
@ghjhf I ll Check on this ThankYou :)
@ghjhf ThankYou for your time your answer works fine.
@Greenikl Was ur problem solved? I dnt know where the function calculateBounds from @ghjhf to put.
You also can use insets. For example:
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/calendar_circle"
android:insetRight="5dp"
android:insetLeft="5dp"
android:insetBottom="5dp"
android:insetTop="5dp" />
@Gidroshvandel It works fine !!! This is really easiest way to reduce circle.
Where do i add the inset?
this is mine my_selector.xml code:
<item android:state_checked="true" android:drawable="@drawable/shape_selection_bg" /> <item android:state_pressed="true" android:drawable="@drawable/shape_selection_bg" /> <item android:drawable="@android:color/transparent" />shape_selection_bg.xml :
<corners android:radius="2dp" /> <solid android:color="@color/c_1495eb" /> <stroke android:width="1dp" android:color="@android:color/transparent" />
Nice Idea, If we need a smaller circle for background, the way put stroke color same as background
You also can use insets. For example:
<inset xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/calendar_circle" android:insetRight="5dp" android:insetLeft="5dp" android:insetBottom="5dp" android:insetTop="5dp" />
Where I need to set it?
Most helpful comment
You also can use insets. For example: