欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 實(shí)現(xiàn)廣告歡迎界面(倒計(jì)時(shí))

 更新時(shí)間:2017年12月28日 08:57:53   作者:Rain911  
前些時(shí)候就是別人問(wèn)我他的android APP怎么做一個(gè)廣告的歡迎界面,就是過(guò)幾秒后自動(dòng)跳轉(zhuǎn)到主界面的實(shí)現(xiàn)。下面通過(guò)本文給大家介紹Android 實(shí)現(xiàn)廣告歡迎界面(倒計(jì)時(shí))的方法,需要的朋友參考下吧

前些時(shí)候就是別人問(wèn)我他的android APP怎么做一個(gè)廣告的歡迎界面,就是過(guò)幾秒后自動(dòng)跳轉(zhuǎn)到主界面的實(shí)現(xiàn)。

也就是下面這種類似的效果。要插什么廣告的話你就換張圖吧。

那么我就思考了下,就用了android 的一個(gè)動(dòng)畫(huà)類Animation...其實(shí)在Android 的API開(kāi)發(fā)文檔上就有的一個(gè)東西。自己可以去查下看。就像下面的這個(gè)圖上面的一樣的。也是屬于界面View 下的一個(gè)類方法...

其實(shí)這個(gè)東西,怎么講呢。

咱主要的話還是來(lái)一個(gè)小白都看的懂的一個(gè)教程類的文章吧。

第一步的話

咱先開(kāi)始在咱的項(xiàng)目中新建一個(gè)anim的文件夾用來(lái)存等會(huì)要用到的一些  倒計(jì)時(shí) 的文字的動(dòng)態(tài)效果的吧。(想想還是截個(gè)屏吧,怕有些同志還是看不懂...沒(méi)別的意思)

看到了么

        看到了么,就是這樣的,在你的Android項(xiàng)目下的存放資源的那個(gè)文件夾中新建一個(gè)anim文件夾,再新建一個(gè)animation_text.xml

的xml文件,待會(huì)就知道有啥用了。

咱下面

第二步的話,咱就開(kāi)始添加內(nèi)容了。

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
 <alpha
  android:duration="1000"
  android:fromAlpha="0.0"
  android:toAlpha="1.0" />
 <scale
  android:duration="800"
  android:fromXScale="1.5"
  android:fromYScale="1.5"
  android:pivotX="50%"
  android:pivotY="50%"
  android:toXScale="1.0"
  android:toYScale="1.0" />
</set>

上面的效果的話,如果是不知道這些屬性是什么意思的話那你可以百度的,我這一一講的話就感覺(jué)有點(diǎn)啰嗦的了。

咱還是講正題吧,那上面這些寫(xiě)的有什么用呢。就看下面了,那么我們下面就得開(kāi)始把那個(gè)界面布局出來(lái)了吧,然后我們下面就開(kāi)始吧,

做一個(gè)類似我上面的界面吧。咱就用FrameLayout布局了,如果知道是什么布局方式的話,我覺(jué)得應(yīng)該看的懂吧。

<FrameLayout 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/page24"
 tools:context="${relativePackage}.${activityClass}" >
 <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="right"
  android:orientation="horizontal" >
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="right"
   android:text="廣告倒計(jì)時(shí):"
   android:textColor="#ffffff"
   android:textSize="20sp" />
  <TextView
   android:id="@+id/textView"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="right"
   android:text="5"
   android:textColor="#ffffff"
   android:textSize="20sp" />
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="right"
   android:text="s"
   android:textColor="#ffffff"
   android:textSize="20sp" />
 </LinearLayout>
</FrameLayout>

下面的話咱就開(kāi)始要寫(xiě)怎么在app內(nèi)部實(shí)現(xiàn)的方法了吧,這就到了我們的Java的程序天地來(lái)了。

這時(shí)候我們就在項(xiàng)目下的src文件下的包里面寫(xiě)上你的Java文件吧。咱慢慢來(lái),別急。

/**
 * 
 * 1.聲明界面
 * 2.定義變量
 * 3.調(diào)用類Animation
 * 4.寫(xiě)方法讓它動(dòng)起來(lái)
 * @author Rain
 *
 */
public class WelcomeActivity extends Activity{
  // 聲明控件對(duì)象
 private TextView textView;
 //聲明時(shí)間有多少;
 private int count = 5;
 private Animation animation;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // 下面的話就是去除標(biāo)題的方法
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.activity_welcome);
  // 初始化控件對(duì)象textView
  textView = (TextView) findViewById(R.id.textView);
  animation = AnimationUtils.loadAnimation(this, R.anim.animation_text);
  handler.sendEmptyMessageDelayed(0, 1000);
 }
 //咱在寫(xiě)一個(gè)計(jì)算Welcome界面的廣告時(shí)間結(jié)束后進(jìn)入主界面的方法
 private int getCount() {
  count--;
  if (count == 0) {
   Intent intent = new Intent(this, MainActivity.class);
   startActivity(intent);
   finish();
  }
  return count;
 }
 //進(jìn)行一個(gè)消息的處理
 @SuppressLint("HandlerLeak")
 private Handler handler = new Handler() {
  public void handleMessage(android.os.Message msg) {
   if (msg.what == 0) {
    textView.setText(getCount()+"");
    handler.sendEmptyMessageDelayed(0, 1000);
    animation.reset();
    textView.startAnimation(animation);
   }
  };
 };
}

用的時(shí)候可得注意導(dǎo)入下包哈。

這樣一個(gè)會(huì)自動(dòng)跳轉(zhuǎn)到主界面的廣告界面就完成了。

總結(jié)

以上所述是小編給大家介紹的Android 實(shí)現(xiàn)廣告歡迎界面(倒計(jì)時(shí)),希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論