最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android實(shí)現(xiàn)閃屏效果

 更新時(shí)間:2018年07月04日 11:05:02   作者:small菜鳥  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)閃屏效果,實(shí)現(xiàn)“一閃而過”效果進(jìn)入頁面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

在登陸一些頁面時(shí),通常能看見“一閃而過”效果并進(jìn)入頁面。下面看看是怎樣實(shí)現(xiàn)這樣的效果的吧

首先,在布局里(可以說和平常沒有什么不同),劃線部分是進(jìn)度條:

<RelativeLayout 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/bg" >
 
  <ImageView
    android:id="@+id/welcome"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="45dp"
    android:src="@drawable/welcome" />
 
  <ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/welcome"
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="70dp"
    />
 
  <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/progressBar"
    android:layout_centerHorizontal="true"
    android:padding="@dimen/padding_medium"
    android:text="@string/welcome"
    android:textAppearance="?android:attr/textAppearanceMedium"
    tools:context=".MainActivity" />
 
</RelativeLayout>

在String中定義:

<resources>
 
  <string name="app_name">ShanP01</string>
  <string name="welcome">歡迎加入!\n一起快樂學(xué)習(xí)!</string>//(\n)實(shí)現(xiàn)換行
  <string name="menu_settings">Settings</string>
  <string name="title_activity_main">MainActivity</string>
  <string name="title_study">學(xué)習(xí)</string>
  <string name="title_search">搜查</string>
  <string name="title_game">游戲</string>
  <string name="title_save">保存</string>
  <string name="title_help">幫助</string>
  <string name="title_activity_welcome">WelcomeActivity</string>
 
</resources>

如果想在運(yùn)行項(xiàng)目時(shí)不顯示標(biāo)題欄,則在想隱藏標(biāo)題欄的Activity中加一句即可(在AndroidManifest.xml文件中):

android:theme="@android:style/Theme.NoTitleBar" 

最主要的實(shí)現(xiàn)方法:

public class WelcomeActivity extends Activity {
 private ImageView welcomeImage;
    @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_welcome);
    welcomeImage=(ImageView) this.findViewById(R.id.welcome);
    AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f, 1.0f);////定義一個(gè)具有淡入效果的對(duì)象
    alphaAnimation.setDuration(3000);//定義閃屏?xí)r間(毫秒)
    welcomeImage.startAnimation(alphaAnimation);
    alphaAnimation.setAnimationListener(new AnimationListener() {
  
  @Override
  public void onAnimationStart(Animation animation) {
  
  
  }
  
  @Override
  public void onAnimationRepeat(Animation animation) {
  
  
  }
  
  @Override
  public void onAnimationEnd(Animation animation) {
  Intent intent=new Intent();
  intent.setClass(WelcomeActivity.this, MainActivity.class);//定義閃屏效果從哪一界面跳到哪一頁面
  startActivity(intent);
  finish();
  
  }
 });
  }
 
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_welcome, menu);
    return true;
  }
  
}

其實(shí)閃屏效果不止這一種,但這是我認(rèn)為簡(jiǎn)便的一種。還有一種:

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_welcome); 
    welcomeImage=(ImageView) this.findViewById(R.id.welcome);   
    AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f,1.0f);////定義1個(gè)具有淡入效果的對(duì)象 
    welcomeImage.startAnimation(alphaAnimation); 
    new Handler().postDelayed(new Runnable() {    
      @Override 
      public void run() { 
        Intent intent=new Intent(); 
        intent.setClass(WelcomeActivity.this, MainActivity.class); 
        startActivity(intent); 
        finish(); 
      } 
    },3000);//細(xì)心不要漏了 
  } 

你覺得哪一種更適合你呢?

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

高要市| 奉化市| 五家渠市| 永泰县| 黎平县| 桓仁| 封开县| 合山市| 宣威市| 观塘区| 财经| 新闻| 临夏县| 喜德县| 湖州市| 鹤庆县| 南岸区| 会昌县| 浦城县| 通道| 洞头县| 富源县| 玛沁县| 黄冈市| 南宫市| 河池市| 菏泽市| 刚察县| 额济纳旗| 六枝特区| 宁城县| 分宜县| 河源市| 灵武市| 肃北| 万安县| 万荣县| 绩溪县| 清丰县| 永德县| 铁岭市|