其中的LinearLayout使用了

来源:互联网 发布:数据库安全的重要性 编辑:程序博客网 时间:2024/05/22 18:33
1
2
3
4
5
6
7
8
9
10
11
12
<?xmlversion=”1.0″ encoding=”utf-8″?>
<LinearLayoutxmlns:android=”http://schemas.android.com/apk/res/android”    android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:background=”@drawable/antelope_canyon”>
<TextViewandroid:text=”@+id/TextView01″
android:id=”@+id/TextView01″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” >
</TextView>
</LinearLayout>

其中的LinearLayout使用了 背景图片antelope_canyon。

如果仔细观察程序的运行过过程,我们首先看到了黑色的activity背景,然后才看到背景图被加载,那是因为在activity start以后,我们才能调用setContentView设置我们的layout,然后才绘制我们在layout中放置的背景图。而在此之前,程序中绘制的是android中默认黑色背景。 这样会给用户感觉我们的activity启动较慢。
然而,如果将背景图定义在一个主题中,如下:

?
1
2
3
4
5
6
7
<?xmlversion=”1.0″ encoding=”utf-8″?>
<resources>
<stylename=”Theme.Droidus” parent=”android:Theme”>
<itemname=”android:windowBackground”>@drawable/antelope_canyon</item>
<itemname=”android:windowNoTitle”>true</item>
</style>
0 0
原创粉丝点击