I have crated an activity with scrollView which holds several buttons and textviews. Before I add the DatePicker into my scrollView, the FPS can keep 60fps. But I don't understand why the FPS drops dramaticly when I added the DatePicker. And I have not find out other widget have such bad performance.
Why I am concerning about the performance of this DatePicker? Because I want to show this DatePicker in a popup window with popup animation. The animation jerking all the time because of the poor performance of the DatePicker. I really want improve it. Pease give me some hint about that.
Here is my xml file which I have added the DatePicker.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/common_white"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test_db" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/backup_database"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="backup_database" />
<Button
android:id="@+id/restore_database"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="restore_database" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/test_result"
android:text="hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<DatePicker
android:id="@+id/test_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"></DatePicker>
</LinearLayout>
</ScrollView>
</LinearLayout>
And here is how I init the DatePicker
Calendar today = Calendar.getInstance();
int year = today.get(Calendar.YEAR);
int month = today.get(Calendar.MONTH) + 1;
int day = today.get(Calendar.DAY_OF_YEAR);
DatePicker picker = (DatePicker) findViewById(R.id.test_picker);
picker.setCalendarViewShown(false);
picker.updateDate(year, month, day);
GPU rendering profile without DatePicker over 60FPS(I cannot post this picture because of short of reputation) GPU rendering profile with DatePicker less than 60FPS
GPU rendering profile with DatePicker less than 60FPS
Hierarchy View analysis with DatePicker, measure more than 1ms, draw more than 15 ms, and of course it cannot reach 60FPS.
Hierarchy View analysis with DatePicker
And I think my phone is not that slow, as it could easily got 60 FPS when running the Palette example from support v7 example which holds many textviews and imageviews. Here is the screenshot.(I cannot post this picture because of short of reputation)