帧布局,简单理解可以说是将各个页面或图片层叠放置,如例图:
layout文件夹下面的xml文件(初学者要注意喽:xml文件应该选择FrameLayout 的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" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:background="@drawable/blog_title" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:paddingLeft="2dp"
android:paddingTop="6dp"
android:layout_gravity="left"
android:src="@drawable/find" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="14dp"
android:paddingTop="20dp"
android:text="@string/find" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:layout_gravity="center_horizontal"
android:text="@string/blog" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/loginname"
android:paddingTop="70dp"/>
<EditText
android:id="@+id/uname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="100dp"
android:hint="@string/uname"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/password"
android:paddingTop="140dp"/>
<EditText
android:id="@+id/pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="170dp"
android:hint="@string/upassword"
android:inputType="textPassword"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:background="@drawable/regist1"
android:paddingTop="220dp"
android:text="@string/regist" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:paddingTop="220dp"
android:background="@drawable/login1"
android:text="@string/login" />
</FrameLayout>
AndroidManifest.xml文件
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.derun.activity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name=".Layout_blog" android:label="layout5">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
java文件,Layout_blog.java文件
package com.derun.activity;
import android.app.Activity;
import android.os.Bundle;
public class Layout_blog extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.layout5);
}
}