<?xml version="1.0" encoding="utf-8"?>
<translate
android:fromYDelta="0"
android:toYDelta="-100%p"
android:duration="1000"/>
左右滚动动画
x\_in.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="1000"/>
x\_out.xml
<?xml version="1.0" encoding="utf-8"?>
<translate
android:fromXDelta="0"
android:toXDelta="-100%p"
android:duration="1000"/>
### (2)layout文件引用ViewFlipper
<ViewFlipper
android:id="@+id/filpper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoStart="true"
android:flipInterval="2000"
android:inAnimation="@anim/x_in"
android:outAnimation="@anim/x_out"/>
### (3)activity中java代码实现ViewFlipper跑马灯效果
TextView textView;
ViewFlipper viewFlipper;
viewFlipper= (ViewFlipper) findViewById(R.id.filpper);
for (int i = 0; i < 5; i++) {
View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.layout_custom, null);
textView = view.findViewById(R.id.myte1);
textView.setText("sssssssss===="+i);
viewFlipper.addView(view);
}
4、ViewFlipper的item点击事件——demo链接:[https://download.youkuaiyun.com/download/meixi\_android/10815720]( )
5、demo云盘链接:[https://pan.baidu.com/s/1AvqpfbzCAXtZ-TLVmEUyvw]( )
在线回复云盘密码:qq1085220040
6、可实现banner轮播图效果
================
### 左右跑马灯
<LinearLayout
android:id="@+id/ll\_bottom"
android:layout\_width="match\_parent"
android:layout\_height="wrap\_content"
android:layout\_alignParentBottom="true"
android:background="#FDC74B">
<TextView
android:id="@+id/tv\_message"
android:layout\_width="match\_parent"
android:layout\_height="wrap\_content"
android:layout\_marginLeft="15pt"
android:layout\_marginRight="15pt"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center\_vertical"
android:includeFontPadding="false"
android:marqueeRepeatLimit="marquee\_forever"
android:paddingBottom="15pt"
android:paddingTop="15pt"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="36pt" />
public class StringUtil {
//长度加倍
public static String multiplyString(String str, int number) {
if (str == null) {
throw new NullPointerException("String is null!");
}
if ("".equals(str)) {
throw new IllegalArgumentException("The length of string is zero !");
}
if (number == 0) {
throw new IllegalArgumentException("Number is zero!");
}
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < number; i++) {
buffer.append(str);
}
return buffer.toString();
}
}
tvMessage.setText(aboutUsResult.getData().getApkmsg() + StringUtil.multiplyString(" ", 30));