May I know how to resize the CalendarView
in Android?
The CalendarView
occupied more than half of the screen.
I wish to make it smaller, perhaps 40% of the screen. Thanks.
Default CalendarView size in my smartphone, occupied more than half
My current XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ada.landing.MainActivity">
<CalendarView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/calendarView"
android:firstDayOfWeek="2"/></RelativeLayout>
I tried another way to define CalendarView
, but the overall height reduced but it does not shrink by ratio:
<CalendarView
android:layout_width="500dp"
android:layout_height="200dp"
android:id="@+id/calendarView"
android:firstDayOfWeek="2" />
I think CalendarView is not (really) resizeable because Android adapts the size of this view to allow user to have a great experience using this view. I think the commun size is when use a DatePickerDialog. DatePickerDialog
CalendarView needs a minimum height and width.
If you really want to resize your calendarView, maybe try to resize(or scale) it programmatically with this :
float scalingFactor = 0.5f; // scale down to half the size
view.setScaleX(scalingFactor);
view.setScaleY(scalingFactor);