Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
自定义视图膨胀导致Android性能问题_Android_Performance_Android Inflate - Fatal编程技术网

自定义视图膨胀导致Android性能问题

自定义视图膨胀导致Android性能问题,android,performance,android-inflate,Android,Performance,Android Inflate,我已经创建了一个为特定年份显示的月份平铺网格的自定义视图 它拥有12个代表每个月的日期牌。 看起来是这样的: 每个磁贴都使用以下XML进行充气: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"

我已经创建了一个为特定年份显示的月份平铺网格的自定义视图

它拥有12个代表每个月的日期牌。 看起来是这样的:

每个磁贴都使用以下XML进行充气:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:gravity="center_horizontal|center_vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/date_tile_margin"
        android:layout_marginRight="@dimen/date_tile_margin"
        android:layout_marginTop="2dp"
        android:layout_marginBottom="2dp">

    <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

        <Button
                android:id="@+id/dateTile"
                android:layout_height="@dimen/date_tile_height"
                android:layout_width="@dimen/date_tile_width"
                android:textColor="#B7BAAB"
                />

        <com.endilo.views.LetterSpacingTextView
                android:id="@+id/dateTileCenterLabel"
                android:layout_width="@dimen/date_tile_height"
                android:layout_height="@dimen/date_tile_width"
                android:gravity="center_vertical|center_horizontal"
                android:scaleX="0.6"
                android:textSize="40sp"
                android:textColor="#BCBFAF"/>

    </FrameLayout>

    <CheckBox
            android:id="@+id/dateTileCheckbox"
            android:button="@drawable/check_green"
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="-20dp"
            android:focusable="false"/>

    <TextView
            android:id="@+id/dateTileMonthLabel"
            android:layout_width="wrap_content"
            android:layout_marginTop="-12dp"
            android:text="Jan"
            android:layout_height="wrap_content"/>

</LinearLayout>

当谈到一年时,每个
DateTile
充气大约需要30-50毫秒,这是一个
DateGridView
it任务~40*12=0.5秒充气一年。 我需要充气至少3页,因为我在显示上一年和下一年的页面适配器中使用了它

有没有办法使膨胀更快,或者重复使用相同的布局来更快地创建12个单独的日期图块