android – CalendarView需要很长时间才能显示

前端之家收集整理的这篇文章主要介绍了android – CalendarView需要很长时间才能显示前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用CalendarView上的应用程序.
我必须以小线性布局显示calendarView.

显示整个页面时出现问题,该页面包含小线性布局中的calendarView.
– >这需要10秒才能显示,&这是很多时间……

布局中没有其他东西.

这是我的xml和snap …

任何帮助都会受到强烈关注……

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical" >
  6.  
  7. <LinearLayout
  8. android:layout_width="fill_parent"
  9. android:layout_height="fill_parent" >
  10.  
  11. <LinearLayout
  12. android:layout_width="0dp"
  13. android:layout_height="fill_parent"
  14. android:layout_weight="1"
  15. android:orientation="vertical" >
  16.  
  17. <RelativeLayout
  18. android:layout_width="fill_parent"
  19. android:layout_height="0dp"
  20. android:layout_weight="30"
  21. android:paddingLeft="30dp" >
  22.  
  23. <TextView
  24. android:id="@+id/txtDate"
  25. android:layout_width="wrap_content"
  26. android:layout_height="wrap_content"
  27. android:text="My Calendar"
  28. android:textSize="50sp" />
  29.  
  30. <View
  31. android:layout_width="fill_parent"
  32. android:layout_height="2dp"
  33. android:layout_alignParentBottom="true"
  34. android:layout_marginBottom="40dp"
  35. android:layout_marginRight="30dp"
  36. android:background="@android:color/black" />
  37. </RelativeLayout>
  38.  
  39. <RelativeLayout
  40. android:layout_width="fill_parent"
  41. android:layout_height="0dp"
  42. android:layout_weight="70"
  43. android:paddingBottom="30dp"
  44. android:paddingLeft="20dp"
  45. android:paddingRight="20dp"
  46. android:paddingTop="30dp" >
  47.  
  48. <LinearLayout
  49. android:layout_width="fill_parent"
  50. android:layout_height="fill_parent"
  51. android:gravity="center"
  52. android:orientation="vertical" >
  53.  
  54. <ListView
  55. android:id="@+id/list_task"
  56. android:layout_width="fill_parent"
  57. android:layout_height="wrap_content" >
  58. </ListView>
  59. </LinearLayout>
  60. </RelativeLayout>
  61. </LinearLayout>
  62.  
  63. <LinearLayout
  64. android:layout_width="0dp"
  65. android:layout_height="fill_parent"
  66. android:layout_weight="1"
  67. android:orientation="vertical" >
  68.  
  69. <RelativeLayout
  70. android:layout_width="fill_parent"
  71. android:layout_height="0dp"
  72. android:layout_weight="30" >
  73.  
  74. <CalendarView
  75. android:id="@+id/cal_small"
  76. android:layout_width="250dp"
  77. android:layout_height="250dp"
  78. android:layout_centerHorizontal="true"
  79. android:background="@android:color/darker_gray"
  80. android:showWeekNumber="false"
  81. android:animateLayoutChanges="false"
  82. android:clipChildren="false"
  83. android:drawingCacheQuality="low"
  84. android:soundEffectsEnabled="false"
  85. android:hapticFeedbackEnabled="false"
  86. />
  87.  
  88. <View
  89. android:layout_width="fill_parent"
  90. android:layout_height="2dp"
  91. android:layout_alignParentBottom="true"
  92. android:layout_marginBottom="40dp"
  93. android:layout_marginLeft="30dp"
  94. android:layout_marginRight="30dp"
  95. android:background="@android:color/black" />
  96. </RelativeLayout>
  97.  
  98. <RelativeLayout
  99. android:layout_width="fill_parent"
  100. android:layout_height="0dp"
  101. android:layout_weight="70" >
  102.  
  103. <LinearLayout
  104. android:layout_width="fill_parent"
  105. android:layout_height="fill_parent"
  106. android:layout_marginBottom="30dp"
  107. android:layout_marginRight="10dp"
  108. android:layout_marginTop="30dp"
  109. android:orientation="vertical" >
  110.  
  111. <LinearLayout
  112. android:layout_width="fill_parent"
  113. android:layout_height="0dp"
  114. android:layout_weight="8" >
  115.  
  116. <ListView
  117. android:id="@+id/list1"
  118. android:layout_width="wrap_content"
  119. android:layout_height="wrap_content"
  120. android:paddingLeft="30dp" >
  121. </ListView>
  122. </LinearLayout>
  123.  
  124. <ListView
  125. android:layout_width="wrap_content"
  126. android:layout_height="wrap_content" >
  127. </ListView>
  128. </LinearLayout>
  129. </RelativeLayout>
  130. </LinearLayout>
  131. </LinearLayout>
  132.  
  133. </LinearLayout>

解决方法

看起来非常简单,但我不小心测试了这个,它运作良好.我希望这也会对你有所帮助……

首先创建单独的xml文件,该文件仅包含CalendarView.名为“cal_view.xml”

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:orientation="vertical" >
  6.  
  7. <android.widget.CalendarView
  8. android:layout_width="200dp"
  9. android:layout_height="200dp" />
  10.  
  11. </LinearLayout>

然后将此xml文件包含在主xml文件中,如下所示.
而不是您的CalanderView,包括xml文件.

  1. <include
  2. android:id="@+id/subCategory"
  3. layout="@layout/cal_view" />

猜你在找的Android相关文章