CalendarView takes much time for displaying

后端 未结 4 1872
感情败类
感情败类 2021-02-06 14:55

i am working on an application on CalendarView. i have to show calendarView in a small linear-layout.

problem occurs while displaying a whole page which contains calenda

相关标签:
4条回答
  • 2021-02-06 15:26

    None of the above answers worked for me, I just changed the width and height to "fill_parent" and now everything works fine for me.

    <CalendarView
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"/>
    
    0 讨论(0)
  • 2021-02-06 15:29

    Putting the CalendarView in a FrameLayout will solve the problem.. i tested it and it work perfectly without glitshing!!!

    here is a XML code example:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#cc00b1cc">
    
        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginTop="102dp"
            android:layout_alignParentBottom="true">
    
            <CalendarView
                android:layout_width="425dp"
                android:layout_height="374dp"
                android:id="@+id/calendarView"
                android:layout_gravity="left|top" />
        </FrameLayout>
    </RelativeLayout>
    
    0 讨论(0)
  • 2021-02-06 15:38

    It seems very simple but accidentally i have tested this, and it works well. I hope this will also help you...

    First create separate xml file which contains only CalendarView. Named “cal_view.xml”

    <?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:orientation="vertical" >
    
        <android.widget.CalendarView
            android:layout_width="200dp"
            android:layout_height="200dp" />
    
    </LinearLayout> 
    

    Then include this xml file in to your main xml file, just like following. Instead of your CalanderView, include the xml file.

     <include
         android:id="@+id/subCategory"
         layout="@layout/cal_view" />
    
    0 讨论(0)
  • 2021-02-06 15:39

    As you mention your problem,

    Issues

    Your resource xml file (layout) not in optimal way. As android guideline don't use static height and weight for ViewGroup. Please read http://developer.android.com/training/improving-layouts/optimizing-layout.html

    Solution :

    In My opinion, you should create your own class for creating Calendar view.In which you apply all the properties and attribute.

    I am show a demo application for the Calender view.http://www.androidviews.net/2013/01/ics-calendarview/ In these application having a better way to use the calendar view. also I am mention some Git URL for the other an custom Calendar view

    • https://github.com/dwivedi/android-times-square
    • https://github.com/dwivedi/ExtendedCalendarView
    • https://github.com/SimonVT/android-calendarview

    In above Application, showing the right way to use CalendarView

    Here I am showing screenshot for the Calenderview application

    enter image description here enter image description here enter image description here

    If any problem, Please Let me know, I will create sample demo for the same.

    0 讨论(0)
提交回复
热议问题