这个demo实现了对控件的绽放功能,其实要实现这个功能,只需在布局文件中将控件的android:scaleType=”fitXY”这个属性设置为在横向和纵向拉伸即可。
本例中还引用了android:fitsSystemWindows=”true”这个属性,意思是指设置应用布局时是否考虑系统窗口布局;如果为true,将调整系统窗口布局以适应你自定义的布局。比如系统有状态栏,应用也有状态栏时。
本例使用的是帧布局,帧布局就如同photoshop的图层的概念,在一个布局之上再添加一个布局层。
同时在配置文件中对activity应用了去除titlebar,和全屏的样式。
布局文件activity_overscan.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/frantic"
android:scaleType="fitXY"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/box_white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Content"/>
</FrameLayout>
配置文件中设置activity
<activity
android:name="com.example.apidemos.app.activity.OverScanActivity"
android:label="@string/activity_overscan"
android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="COM_FISHTOSKY_CODE" />
</intent-filter>
</activity>