Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce size of CalendarView?

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

CalendarView

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

<CalendarView
            android:layout_width="500dp"
            android:layout_height="200dp"
            android:id="@+id/calendarView"
            android:firstDayOfWeek="2" />
like image 658
CHAN HAU YEEN Avatar asked Sep 18 '16 13:09

CHAN HAU YEEN


2 Answers

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);

like image 55
Cocorico Avatar answered Sep 25 '22 21:09

Cocorico


if you want resize

 android:scaleY="1.1" -vertically
like image 34
Subhash Chandru Avatar answered Sep 25 '22 21:09

Subhash Chandru