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

Android仿淘寶頭條基于TextView實(shí)現(xiàn)上下滾動(dòng)通知效果

 更新時(shí)間:2017年03月10日 09:52:37   作者:艾妮旭  
這篇文章主要介紹了Android TextView實(shí)現(xiàn)上下滾動(dòng)通知效果,需要的朋友可以參考下

最近有個(gè)項(xiàng)目需要實(shí)現(xiàn)通知欄的上下滾動(dòng)效果,仿淘寶頭條的那種。

我從網(wǎng)上看了一些代碼,把完整的效果做了出來。如圖所示:

具體代碼片段如下:

1.在res文件夾下新建anmin文件夾,在這個(gè)文件夾里創(chuàng)建兩個(gè)文件

(1).anim_marquee_in.xml進(jìn)入時(shí)動(dòng)畫

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
> 
<translate 
android:duration="1500" 
android:fromYDelta="100%p" 
android:toYDelta="0"> 
</translate> 
</set> 

(2).anim_marquee_out.xml退出時(shí)動(dòng)畫

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
<translate 
 android:duration="1500" 
 android:fromYDelta="0" 
 android:toYDelta="-100%p"> 
</translate> 
</set> 

2.activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 xmlns:tools="http://schemas.android.com/tools" 
 android:id="@+id/activity_main" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 tools:context="com.spore.marqueeview.MainActivity" > 
 <ViewFlipper 
  android:id="@+id/marquee_view" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:autoStart="true" 
  android:background="#fff" 
  android:flipInterval="2500" 
  android:inAnimation="@anim/anim_marquee_in" 
  android:outAnimation="@anim/anim_marquee_out" > 
 </ViewFlipper> 
</RelativeLayout> 

3.noticelayout.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 android:layout_width="match_parent" 
 android:layout_height="wrap_content" 
 android:orientation="horizontal" > 
 <ImageView 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:padding="5dp" 
  android:src="@drawable/icon_home_notice" /> 
 <TextView 
  android:layout_width="match_parent" 
  android:layout_height="match_parent" 
  android:gravity="center_vertical" 
  android:paddingLeft="10dp" 
  android:singleLine="true" 
  android:text="[2017-02-28 08:00]通知:上午九點(diǎn)整開會(huì)!" 
  android:textSize="18sp" /> 
</LinearLayout> 

4.MainActivity.java

package com.iponkan.textviewupdown; 
import com.example.textviewupdown.R; 
import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
import android.view.View; 
import android.widget.ViewFlipper; 
public class MainActivity extends Activity { 
 @Override 
 protected void onCreate(Bundle savedInstanceState) { 
  super.onCreate(savedInstanceState); 
  setContentView(R.layout.activity_main); 
  // 為ViewFlipper添加廣告條 
  ViewFlipper vf = (ViewFlipper) findViewById(R.id.marquee_view); 
  vf.addView(View.inflate(this, R.layout.noticelayout, null)); 
  vf.addView(View.inflate(this, R.layout.noticelayout, null)); 
  vf.addView(View.inflate(this, R.layout.noticelayout, null)); 
 } 
 @Override 
 public boolean onCreateOptionsMenu(Menu menu) { 
  // Inflate the menu; this adds items to the action bar if it is present. 
  getMenuInflater().inflate(R.menu.main, menu); 
  return true; 
 } 
} 

以上所述是小編給大家介紹的Android仿淘寶頭條基于TextView實(shí)現(xiàn)上下滾動(dòng)通知效果,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Android之開發(fā)消息通知欄

    Android之開發(fā)消息通知欄

    本文主要介紹了Android開發(fā)消息通知欄的相關(guān)知識(shí)。具有很好的參考價(jià)值。下面跟著小編一起來看下吧
    2017-04-04
  • Android下載gradle失敗的解決方法

    Android下載gradle失敗的解決方法

    這篇文章主要介紹了Android下載gradle失敗的解決方法,文章通過圖文結(jié)合的方式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-06-06
  • Android使用代碼動(dòng)態(tài)生成界面

    Android使用代碼動(dòng)態(tài)生成界面

    這篇文章主要為大家詳細(xì)介紹了Android使用代碼動(dòng)態(tài)生成界面,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Android?Studio使用自定義對(duì)話框效果

    Android?Studio使用自定義對(duì)話框效果

    這篇文章主要為大家詳細(xì)介紹了Android?Studio使用自定義對(duì)話框效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • Android使用Fragment實(shí)現(xiàn)兼容手機(jī)和平板的程序

    Android使用Fragment實(shí)現(xiàn)兼容手機(jī)和平板的程序

    這篇文章主要介紹了Android使用Fragment實(shí)現(xiàn)兼容手機(jī)和平板的程序,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下
    2021-04-04
  • Android利用HelloChart繪制曲線

    Android利用HelloChart繪制曲線

    這篇文章主要為大家詳細(xì)介紹了Android利用HelloChart繪制曲線,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • Android自定義個(gè)性化的Dialog示例

    Android自定義個(gè)性化的Dialog示例

    這篇文章主要介紹了Android自定義個(gè)性化的Dialog,結(jié)合實(shí)例形式分析了自定義Dialog的功能、樣式、布局等相關(guān)操作技巧,需要的朋友可以參考下
    2017-02-02
  • Android  ADB詳細(xì)介紹及用法

    Android ADB詳細(xì)介紹及用法

    本文主要介紹Android ADB,這里整理了Android ADB的文檔資料,詳細(xì)介紹了adb 命令,有需要的小伙伴可以參考下
    2016-08-08
  • Android?ViewPager你可能不知道的刷新操作分享

    Android?ViewPager你可能不知道的刷新操作分享

    這篇文章主要為大家詳細(xì)介紹了Android中ViewPager你可能不知道的刷新操作,文中的示例代碼講解詳細(xì),具有一定的學(xué)習(xí)價(jià)值,需要的可以參考一下
    2023-05-05
  • Android簡單判斷某個(gè)APK是否已經(jīng)安裝的方法

    Android簡單判斷某個(gè)APK是否已經(jīng)安裝的方法

    這篇文章主要介紹了Android簡單判斷某個(gè)APK是否已經(jīng)安裝的方法,通過針對(duì)應(yīng)用程序包名的讀取及判斷獲取安裝信息,需要的朋友可以參考下
    2016-08-08

最新評(píng)論