1、
public class IndexActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_index);
// 加入定时切换界面功能
Thread t = new Thread() {
@Override
public void run() {
// 定时
try {
Thread.sleep(2000);
// 切换下一个界面
Intent in = new Intent(IndexActivity.this,
MainActivity.class);
startActivity(in);
// 当切换到下一个界面后,当前封面就关闭了
finish();
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();
}
}
完成主界面即可。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/main_bg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="55"
android:background="@drawable/top_bg"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7"
android:gravity="center"
android:text="程序员面试宝典"
android:textColor="#ffffff"
android:textSize="14sp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/top_setting_btn" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="665"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="200"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/main_book_icon" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="52" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="58"
android:gravity="center"
android:textSize="30sp"
android:text="欢迎使用"
android:textColor="#ff0000" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="115"
android:orientation="horizontal" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="38" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="404"
android:background="@drawable/main_adv_icon" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="38" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="80"
android:orientation="horizontal"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@drawable/bottom_bg"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bottom_01_b" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bottom_02_a" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/bottom_03_a" />
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>