读书人

[转]技艺和设计模式 - 背景和图像实用

发布时间: 2012-07-15 20:11:39 作者: rapoo

[转]技巧和设计模式 --- 背景和图像实用技巧

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] 修改编码

?

?

@Overridepublic 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>

?


[转]技艺和设计模式 - 背景和图像实用技巧

?

读书人网 >图形图像

热点推荐