为了创建阴影斜角效果,我创建了一个可绘制的xml文件,该文件作为前景'各种FrameLayouts的属性。
我在屏幕上有三个FrameLayouts,其中有一个可绘制的前景,其中一个包含Google地图,我注意到由drawable引起的性能下降(通过与Google地图交互显而易见) 。评论整个可绘制列表并恢复正常性能。
不可否认的是,绘画很多(七种形状,略有不同的颜色和混合,以创造一个漂亮的阴影斜面,让人联想到80年代的军事界面)。据推测,Android每次绘图操作都会执行整个操作,而不是缓存和重用结果?
有人可以建议如何保留视觉功能,但提高性能吗?
可绘制文件:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="@dimen/BevelInset"
android:top="@dimen/BevelInset"
android:bottom="@dimen/BevelInset"
android:right="@dimen/BevelInset">
<shape
android:shape="rectangle">
<corners
android:radius="@dimen/BevelRadius" />
<stroke
android:width="@dimen/BevelEdge"
android:color="@color/ViewBevelColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
<item
android:left="@dimen/BevelInset"
android:top="0dp"
android:bottom="0dp"
android:right="0dp">
<shape
android:shape="rectangle">
<corners
android:radius="5dp" />
<stroke
android:width="5dp"
android:color="@color/ViewBevelDarkColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
<item
android:left="0dp"
android:top="@dimen/BevelInset"
android:bottom="0dp"
android:right="0dp">
<shape
android:shape="rectangle">
<corners
android:radius="@dimen/BevelRadius" />
<stroke
android:width="@dimen/BevelEdge"
android:color="@color/ViewBevelDarkColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
<item
android:left="0dp"
android:top="0dp"
android:bottom="@dimen/BevelInset"
android:right="0dp">
<shape
android:shape="rectangle">
<corners
android:radius="@dimen/BevelRadius" />
<stroke
android:width="@dimen/BevelEdge"
android:color="@color/ViewBevelLightColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
<item
android:left="0dp"
android:top="0dp"
android:bottom="0dp"
android:right="@dimen/BevelInset">
<shape
android:shape="rectangle">
<corners
android:radius="@dimen/BevelRadius" />
<stroke
android:width="@dimen/BevelEdge"
android:color="@color/ViewBevelLightColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
<item
android:left="@dimen/BevelBlend"
android:top="@dimen/BevelBlend"
android:bottom="@dimen/BevelBlend"
android:right="@dimen/BevelBlend">
<shape
android:shape="rectangle">
<corners
android:radius="@dimen/BevelRadius" />
<stroke
android:width="@dimen/BevelEdge"
android:color="@color/ViewBevelBlendColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
<item>
<shape
android:shape="rectangle">
<stroke
android:width="@dimen/BevelEdge"
android:color="@color/ViewBevelColour" />
<solid
android:color="@color/TransparentColour" />
</shape>
</item>
</layer-list>
样式值:
<resources>
<color name="ViewBevelColour">#ff004f4f</color>
<color name="ViewBevelDarkColour">#3f000000</color>
<color name="ViewBevelLightColour">#3fffffff</color>
<color name="ViewBevelBlendColour">#7f004f4f</color>
<color name="BackgroundColour">#ff000000</color>
<color name="TransparentColour">#00ffffff</color>
<dimen name="BevelInset">3dp</dimen>
<dimen name="BevelEdge">5dp</dimen>
<dimen name="BevelRadius">5dp</dimen>
<dimen name="BevelBlend">1dp</dimen>
<dimen name="BevelTotal">8dp</dimen>
<color name="DividerColour">#ff00ff00</color>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowBackground">@color/BackgroundColour</item>
<item name="android:textColor">#ffff0000</item>
</style>
</resources>