我正在使用CalendarView上的应用程序.
我必须以小线性布局显示calendarView.
我必须以小线性布局显示calendarView.
显示整个页面时出现问题,该页面包含小线性布局中的calendarView.
– >这需要10秒才能显示,&这是很多时间……
布局中没有其他东西.
这是我的xml和snap …
任何帮助都会受到强烈关注……
- <?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" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" >
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="30"
- android:paddingLeft="30dp" >
- <TextView
- android:id="@+id/txtDate"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="My Calendar"
- android:textSize="50sp" />
- <View
- android:layout_width="fill_parent"
- android:layout_height="2dp"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="40dp"
- android:layout_marginRight="30dp"
- android:background="@android:color/black" />
- </RelativeLayout>
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="70"
- android:paddingBottom="30dp"
- android:paddingLeft="20dp"
- android:paddingRight="20dp"
- android:paddingTop="30dp" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="center"
- android:orientation="vertical" >
- <ListView
- android:id="@+id/list_task"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
- </ListView>
- </LinearLayout>
- </RelativeLayout>
- </LinearLayout>
- <LinearLayout
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="30" >
- <CalendarView
- android:id="@+id/cal_small"
- android:layout_width="250dp"
- android:layout_height="250dp"
- android:layout_centerHorizontal="true"
- android:background="@android:color/darker_gray"
- android:showWeekNumber="false"
- android:animateLayoutChanges="false"
- android:clipChildren="false"
- android:drawingCacheQuality="low"
- android:soundEffectsEnabled="false"
- android:hapticFeedbackEnabled="false"
- />
- <View
- android:layout_width="fill_parent"
- android:layout_height="2dp"
- android:layout_alignParentBottom="true"
- android:layout_marginBottom="40dp"
- android:layout_marginLeft="30dp"
- android:layout_marginRight="30dp"
- android:background="@android:color/black" />
- </RelativeLayout>
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="70" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_marginBottom="30dp"
- android:layout_marginRight="10dp"
- android:layout_marginTop="30dp"
- android:orientation="vertical" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="8" >
- <ListView
- android:id="@+id/list1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:paddingLeft="30dp" >
- </ListView>
- </LinearLayout>
- <ListView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
- </ListView>
- </LinearLayout>
- </RelativeLayout>
- </LinearLayout>
- </LinearLayout>
- </LinearLayout>
解决方法
看起来非常简单,但我不小心测试了这个,它运作良好.我希望这也会对你有所帮助……
首先创建单独的xml文件,该文件仅包含CalendarView.名为“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>
然后将此xml文件包含在主xml文件中,如下所示.
而不是您的CalanderView,包括xml文件.
- <include
- android:id="@+id/subCategory"
- layout="@layout/cal_view" />