Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android 游戲開發 界面設計(二)

Android 游戲開發 界面設計(二)

編輯:關於Android編程


----------------------------------------------.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
          android:id="@+id/mainMenuBackground"
          android:src="@drawable/title_background"
          android:adjustViewBounds="true"
          android:gravity="center_vertical"
          android:scaleType="fitXY"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"/>


    <LinearLayout
    android:background="@drawable/custom_toast_border"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_gravity="center"
    android:padding="10dp">
   
   <ImageView
       android:id="@+id/babyButton"
       android:src="@drawable/ui_button_baby"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:layout_gravity="center_horizontal"
       android:clickable="true" />
      
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor= "#FFFFFF"
android:textSize="14sp"
android:focusable="false"
android:layout_gravity="center_horizontal"
android:text="都是低調點速度來到了多少了多少了多少水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水水"
android:id="@+id/babyText"/>
        
<ImageView
   android:id="@+id/kidsButton"
   android:src="@drawable/ui_button_kids"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center_horizontal"
   android:clickable="true"
   android:layout_marginTop="15dp"/>
  
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor= "#FFFFFF"
android:textSize="14sp"
android:focusable="false"
android:layout_gravity="center_horizontal"
android:text="@string/kids_description"
android:id="@+id/kidsText"/>

<ImageView
   android:id="@+id/adultsButton"
   android:src="@drawable/ui_button_adults"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center_horizontal"
   android:clickable="true"
   android:layout_marginTop="15dp"/>
  
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor= "#FFFFFF"
android:textSize="14sp"
android:focusable="false"
android:layout_gravity="center_horizontal"
android:text="@string/adults_description"
android:id="@+id/adultsText"/>
       
</LinearLayout>
</FrameLayout>


-------------------------------------------drawable/custom_toast_border   Linearlayou的布局
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Thanks to http://hustleplay.wordpress.com/2009/07/23/replicating-default-android-toast/ ! -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">


<solid android:color="#99000000"/>
<padding
android:left="40dp"
android:top="40dp"
android:right="40dp"
android:bottom="40dp" />
<corners android:radius="10dp" />
</shape>

 

 

--------------------------.java
package com.example.xiang1;

 

 

 

 


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;


public class MainActivity extends Activity {
private Animation mButtonFlickerAnimation;
private boolean mPaused;
private View mTicker;
private Animation mAlternateFadeOutAnimation;
private View mStartButton;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


mTicker = findViewById(R.id.ticker);
if (mTicker != null) {


mTicker.setFocusable(true);
mTicker.requestFocus();
mTicker.setSelected(true);


}

 

 

mStartButton = findViewById(R.id.startButton);
mStartButton.setOnClickListener(new OnClickListener() {


public void onClick(View v) {
// TODO Auto-generated method stub


Intent i = new Intent(MainActivity.this,
DifficultyMenuActivity.class);
startActivity(i);


}


});


}


@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();


}
}

 

 

-----------------DifficultyMenuActivity.java  進入到游戲開始的第二個界面
package com.example.xiang1;


import android.app.Activity;
import android.os.Bundle;


public class DifficultyMenuActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.difficulty_menu);
}


}

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved