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

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)上看了一些代碼,把完整的效果做了出來(lái)。如圖所示:

具體代碼片段如下:

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)整開(kāi)會(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ì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論

桐梓县| 荥阳市| 威远县| 正镶白旗| 盐城市| 文安县| 贵定县| 稻城县| 玉屏| 山西省| 微山县| 法库县| 海晏县| 平利县| 蕉岭县| 思茅市| 太仆寺旗| 凌云县| 蒙阴县| 吉首市| 西充县| 景宁| 壤塘县| 武陟县| 沅江市| 定西市| 曲沃县| 云阳县| 罗田县| 长宁区| 遵义市| 赤城县| 扬中市| 吉木乃县| 洛浦县| 全南县| 顺昌县| 彭山县| 南开区| 滁州市| 策勒县|