1.选择恰当的图像尺寸
视图背景图像总会填充整个视图区域
[1] 图像尺寸不合适会导致自动缩放.
[2] 避免实时缩放.
[3] 最好预先缩放到视图大小.
originalImage = Bitmap.createScaledBitmap(
originalImage, // 被缩放图像
view.getWidth(), // 视图宽度
view.getHeight(), // 视图高度
true); // 双线性过滤器
2.窗口背景
[1]默认情况下, 窗口有一个不透明的背景.
[2]有时可以不需要,比如说最高层的视图是不透明的而且最高层的视图覆盖整个窗口layout_width="fill_parent",layout_height="fill_parent".
[3]由[2]就产生了,更新看不见的背景是浪费时间.
解决的方法
[1] 修改编码
@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
setContentView(R.layout.mainview);
// 删除窗口背景
getWindow().setBackgroundDrawable(null);
...
}
[2]修改XML声明
首先确定你的res/values/styles.xml有
<resources>
<style name="NoBackgroundTheme" parent="android:Theme">
<item name="android:windowBackground">@null</item>
</style>
然后编辑 AndroidManifest.xml
<activity android:name="MyApplication"
android:theme="@style/NoBackgroundTheme">
...
</activity>