溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面

發(fā)布時間:2021-08-20 10:41:23 來源:億速云 閱讀:155 作者:小新 欄目:移動開發(fā)

小編給大家分享一下Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

一、實現(xiàn)的效果圖

歡迎界面:

Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面

引導(dǎo)界面1

Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面

引導(dǎo)界面 2

Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面

引導(dǎo)界面 3

Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面

二 、項目的目錄結(jié)構(gòu)

Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面

三、具體的編碼實現(xiàn)

1、歡迎界面的xml布局,activity_welcome:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent" 
 android:background="@drawable/v5_6_2_welcome" 
 android:orientation="vertical" />

2、引導(dǎo)界面的xml布局,activity_guide.xml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:layout_width="fill_parent" 
 android:layout_height="fill_parent" 
 android:orientation="vertical" > 
 
 <ImageView 
  android:id="@+id/iv_guide_picture" 
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent" 
  android:layout_weight="1.0" 
  android:scaleType="fitXY" /> 
 
 <LinearLayout 
  android:id="@+id/ll_bottom_action_bar" 
  android:layout_width="fill_parent" 
  android:layout_height="wrap_content" 
  android:layout_alignParentBottom="true" 
  android:orientation="horizontal" 
  android:padding="7dip" > 
 
  <Button 
   android:id="@+id/btn_register" 
   android:layout_width="fill_parent" 
   android:layout_height="45dip" 
   android:layout_weight="1.5" 
   android:background="@drawable/guide_btn_blue" 
   android:gravity="center" 
   android:singleLine="true" 
   android:text="注 冊" 
   android:textColor="#FFFFFF" 
   android:textSize="15.0sp" /> 
 
  <Button 
   android:id="@+id/btn_look_at_the_people_i_know" 
   android:layout_width="fill_parent" 
   android:layout_height="45dip" 
   android:layout_marginLeft="8dip" 
   android:layout_marginRight="8dip" 
   android:layout_weight="1.0" 
   android:background="@drawable/guide_btn_white" 
   android:gravity="center" 
   android:singleLine="true" 
   android:text="看看我認(rèn)識的人" 
   android:textColor="#000000" 
   android:textSize="15.0sp" /> 
 
  <Button 
   android:id="@+id/btn_login" 
   android:layout_width="fill_parent" 
   android:layout_height="45dip" 
   android:layout_weight="1.5" 
   android:background="@drawable/guide_btn_blue" 
   android:gravity="center" 
   android:singleLine="true" 
   android:text="登 錄" 
   android:textColor="#FFFFFF" 
   android:textSize="15.0sp" /> 
 </LinearLayout> 
</RelativeLayout>

3、在這里還要創(chuàng)建兩個xml資源文件文件來實現(xiàn)自定義按鈕的效果,關(guān)于自定義按鈕的效果實現(xiàn)我會在后面的UI專題詳細(xì)介紹,這里就不在贅述,guide_btn_blue.xml:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
 
 <item android:drawable="@drawable/v5_0_1_guide_blue_default" android:state_focused="true" android:state_pressed="false"/> 
 <item android:drawable="@drawable/v5_0_1_guide_blue_press" android:state_pressed="true"/> 
 <item android:drawable="@drawable/v5_0_1_guide_blue_default"/> 
 
</selector>

guide_btn_white:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
 
 <item android:drawable="@drawable/v5_0_1_guide_black_default" android:state_focused="true" android:state_pressed="false"/> 
 <item android:drawable="@drawable/v5_0_1_guide_black_press" android:state_pressed="true"/> 
 <item android:drawable="@drawable/v5_0_1_guide_black_default"/> 
 
</selector>

  4、然后是動畫效果的xml資源文件,關(guān)于自定義動畫效果的實現(xiàn)我也會在后面的UI專題中詳細(xì)介紹,這里也就不再贅述漸入動畫資源文件,guide_fade_in.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" > 
  
 <alpha android:fromAlpha="0.0" 
   android:toAlpha="1.0" /> 
 
</set>

 漸隱動畫資源文件,guide_fade_out.xml:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
 <scale 
  android:fillAfter="false" 
  android:fromXScale="1.1" 
  android:fromYScale="1.1" 
  android:interpolator="@android:anim/decelerate_interpolator" 
  android:pivotX="50.0%" 
  android:pivotY="50.0%" 
  android:toXScale="1.1" 
  android:toYScale="1.1" /> 
 
 <alpha 
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:fromAlpha="1.0" 
  android:toAlpha="0.0" /> 
 
</set>

放大動畫資源文件,guide_fade_in_scale:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" > 
 
 <scale 
  android:fillAfter="false" 
  android:fromXScale="1.0" 
  android:fromYScale="1.0" 
  android:interpolator="@android:anim/decelerate_interpolator" 
  android:pivotX="50.0%" 
  android:pivotY="50.0%" 
  android:toXScale="1.1" 
  android:toYScale="1.1"/> 
 
</set>

5、開始啟動的歡迎界WelcomeActivity.java:

package com.yangyu.myguideview03; 
 
import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.os.CountDownTimer; 
 
/** 
 * @author yangyu 
 * 功能描述:歡迎界面Activity(Logo) 
 */ 
public class WelcomeActivity extends Activity { 
 
 @Override 
 public void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.activity_welcome); 
 
  /** 
   * millisInFuture:從開始調(diào)用start()到倒計時完成并onFinish()方法被調(diào)用的毫秒數(shù) 
   * countDownInterval:接收onTick(long)回調(diào)的間隔時間 
   */ 
  new CountDownTimer(5000, 1000) { 
   @Override 
   public void onTick(long millisUntilFinished) { 
   } 
 
   @Override 
   public void onFinish() { 
    Intent intent = new Intent(WelcomeActivity.this, GuideActivity.class); 
    startActivity(intent); 
    WelcomeActivity.this.finish(); 
   } 
  }.start(); 
 } 
}

6、引導(dǎo)界面,GuideActivity.java:

package com.yangyu.myguideview03; 
 
import android.app.Activity; 
import android.graphics.drawable.Drawable; 
import android.os.Bundle; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.animation.Animation; 
import android.view.animation.Animation.AnimationListener; 
import android.view.animation.AnimationUtils; 
import android.widget.Button; 
import android.widget.ImageView; 
import android.widget.Toast; 
 
/** 
 * @author yangyu 
 * 功能描述:導(dǎo)引界面(每張圖片都執(zhí)行的動畫順序,漸現(xiàn)、放大和漸隱,結(jié)束后切換圖片和文字 
 * 又開始執(zhí)行 漸現(xiàn)、放大和漸隱,當(dāng)最后一張執(zhí)行完漸隱,切換到第一張,從而達到循環(huán)效果) 
 */ 
public class GuideActivity extends Activity implements OnClickListener{ 
 //定義注冊、登錄和看看我認(rèn)識的人按鈕 
 private Button btnRegister,btnLogin,btnIKnowPeople; 
  
 //顯示圖片的ImageView組件 
 private ImageView ivGuidePicture; 
  
 //要展示的一組圖片資源 
 private Drawable[] pictures; 
  
 //每張展示圖片要執(zhí)行的一組動畫效果 
 private Animation[] animations; 
  
 //當(dāng)前執(zhí)行的是第幾張圖片(資源索引) 
 private int currentItem = 0; 
  
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.activity_guide); 
   
  initView(); 
   
  initData(); 
 } 
 
 /** 
  * 初始化組件 
  */ 
 private void initView(){ 
  //實例化ImageView引導(dǎo)圖片 
  ivGuidePicture = (ImageView) findViewById(R.id.iv_guide_picture); 
   
  //實例化按鈕 
  btnRegister = (Button) findViewById(R.id.btn_register); 
  btnIKnowPeople = (Button) findViewById(R.id.btn_look_at_the_people_i_know); 
  btnLogin = (Button) findViewById(R.id.btn_login); 
 
  //實例化引導(dǎo)圖片數(shù)組 
  pictures = new Drawable[] { getResources().getDrawable(R.drawable.v5_3_0_guide_pic1),getResources().getDrawable(R.drawable.v5_3_0_guide_pic2), 
         getResources().getDrawable(R.drawable.v5_3_0_guide_pic3)}; 
 
  //實例化動畫效果數(shù)組 
  animations = new Animation[] { AnimationUtils.loadAnimation(this, R.anim.guide_fade_in), 
          AnimationUtils.loadAnimation(this, R.anim.guide_fade_in_scale), 
          AnimationUtils.loadAnimation(this, R.anim.guide_fade_out) }; 
 } 
 
 /** 
  * 初始化數(shù)據(jù) 
  */ 
 private void initData(){ 
  //給按鈕設(shè)置監(jiān)聽 
  btnRegister.setOnClickListener(this); 
  btnIKnowPeople.setOnClickListener(this); 
  btnLogin.setOnClickListener(this); 
      
  //給每個動畫效果設(shè)置播放時間 
  animations[0].setDuration(1500); 
  animations[1].setDuration(3000); 
  animations[2].setDuration(1500); 
 
  //給每個動畫效果設(shè)置監(jiān)聽事件 
  animations[0].setAnimationListener(new GuideAnimationListener(0)); 
  animations[1].setAnimationListener(new GuideAnimationListener(1)); 
  animations[2].setAnimationListener(new GuideAnimationListener(2)); 
   
  //設(shè)置圖片動畫初始化默認(rèn)值為0 
  ivGuidePicture.setImageDrawable(pictures[currentItem]); 
  ivGuidePicture.startAnimation(animations[0]); 
 } 
 
 /** 
  * 實現(xiàn)了動畫監(jiān)聽接口,重寫里面的方法 
  */ 
 class GuideAnimationListener implements AnimationListener {    
  private int index; 
 
  public GuideAnimationListener(int index) { 
   this.index = index; 
  } 
 
  @Override 
  public void onAnimationStart(Animation animation) { 
  } 
   
  //重寫動畫結(jié)束時的監(jiān)聽事件,實現(xiàn)了動畫循環(huán)播放的效果 
  @Override 
  public void onAnimationEnd(Animation animation) { 
   if (index < (animations.length - 1)) { 
    ivGuidePicture.startAnimation(animations[index + 1]); 
   } else { 
    currentItem++; 
    if (currentItem > (pictures.length - 1)) { 
     currentItem = 0; 
    } 
    ivGuidePicture.setImageDrawable(pictures[currentItem]); 
    ivGuidePicture.startAnimation(animations[0]); 
   } 
  } 
 
  @Override 
  public void onAnimationRepeat(Animation animation) { 
 
  } 
 
 } 
  
 @Override 
 public void onClick(View v) { 
   switch (v.getId()) { 
   case R.id.btn_register: 
    Toast.makeText(this, "點擊了注冊按鈕", Toast.LENGTH_SHORT).show(); 
    break; 
   case R.id.btn_look_at_the_people_i_know: 
    Toast.makeText(this, "點擊了我認(rèn)識的人按鈕", Toast.LENGTH_SHORT).show(); 
    break; 
   case R.id.btn_login:  
    Toast.makeText(this, "點擊了登錄按鈕", Toast.LENGTH_SHORT).show(); 
    break; 
   default: 
    break; 
   } 
 } 
}

以上是“Android UI如何實現(xiàn)人人網(wǎng)V5.9.2最新版引導(dǎo)界面”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI