Android How to prevent Drawable resizing to fill container

75 views Asked by At

I have a drawable (just a red circle)

<item android:state_pressed="false">
    <shape android:shape="oval">
        <size android:height="12dp" />
        <size android:width="12dp" />
        <solid android:color="@color/colorNonCompliant" />
    </shape>
</item>

I want to use it in a MaterialCalendarView, as a background on the calendar for a single day. The code for it is

class CurrentDayDecorator(context: Activity?, currentDay: CalendarDay) : DayViewDecorator {
    private val drawable: Drawable? = ContextCompat.getDrawable(context!!, R.drawable.ic_circle_noncompliant_calendar)
    var myDay = currentDay
    override fun shouldDecorate(day: CalendarDay): Boolean {
        return day == myDay
    }

    override fun decorate(view: DayViewFacade) {
        view.setSelectionDrawable(drawable!!)
    }

    init {
        // You can set background for Decorator via drawable here
    }
}

But the circle gets resized to fully fit the box/container for that certain day. I want the circle to be smaller, how can I size it accordingly? I tried padding but failed. Thanks in advance

0

There are 0 answers