How to reduce the size of CalendarView?

Can I learn how to resize CalendarView on Android? CalendarView took up more than half the screen. I want to reduce it, perhaps by 40% of the screen. Thanks.

The default CalendarViewView size in my smartphone, busy over 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 decreased, but did not decrease in relation:

Calendarview

 <CalendarView android:layout_width="500dp" android:layout_height="200dp" android:id="@+id/calendarView" android:firstDayOfWeek="2" /> 
+7
android calendarview
source share
7 answers

I think CalendarView is not (really) mutable, because Android adapts the size of this view to allow the user to have a lot of experience using this view. I think community size when using DatePickerDialog. DatePickerDialog

CalendarView requires a minimum height and width.

If you really want to resize your calendar, try resizing it (or scaling it) programmatically with this:

float scalingFactor = 0.5f; // scale down to half the size view.setScaleX(scalingFactor); view.setScaleY(scalingFactor);

+3
source share

There are several different ways to reduce the size of a CalendarView. One of them is that you can manually adjust the size of the view in the .XML file in which you use the calendar. Another way is to create a new layout (for example, a linear layout), adjust the layout to the desired size, and place the CalendarView in that layout.

+1
source share

Here I put code that reduces up to 40% of the width of the calendaring view. Try it.

  <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="1"> <LinearLayout android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="0.4" android:orientation="horizontal" android:weightSum="1"> <CalendarView android:id="@+id/calendarView" android:layout_width="0dip" android:layout_height="match_parent" android:layout_weight="0.4" android:firstDayOfWeek="2" /> </LinearLayout> </LinearLayout> 
+1
source share

You can try the following:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:weightSum="5" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2"> <CalendarView android:id="@+id/calendarView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:firstDayOfWeek="2"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="3"></LinearLayout> </LinearLayout> 
+1
source share

We hope this helps reduce the size of your calendar view.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <CalendarView android:layout_width="200dp" android:layout_height="200dp" android:id="@+id/calendarView" android:firstDayOfWeek="2"/> </LinearLayout> <LinearLayout android:layout_weight="60" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:text="Hello World hello world " android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout> 

Now there is a library that allows you to set the dp size in sdp (Scalable Dp) so that it helps in many screen sizes

Gradle for this

 compile 'com.intuit.sdp:sdp-android:1.0.3' 

Code Example The same example above, but it will support all possible screen sizes.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content"> <CalendarView android:layout_width="@dimen/_100sdp" android:layout_height="@dimen/_100sdp" android:id="@+id/calendarView" android:firstDayOfWeek="2"/> </LinearLayout> <LinearLayout android:layout_weight="60" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:text="Hello World hello world " android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout> 
+1
source share

I tried to answer above, but not to work, what exactly I want. Then later I have a Material Calender View user.

In this case, we can give the width of the tile and the height of the tile according to our requirement. if we want to see a calendar rectangle with a much lower height than the width, we can set the tile width to be greater than the height. Thanks to all who responded.

0
source share

if you want to resize

  android:scaleY="1.1" -vertically 
0
source share