自定义一个View继承TextView
public class MarqueeTextView extends TextView{
public MarqueeTextView(Context context) {
super(context);
}
public MarqueeTextView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MarqueeTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean isFocused() {
return true;
}
}
在activity_main.xml中调用
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f0f"
android:gravity="center"
android:orientation="vertical">
<fanruiqi.bwie.com.week220181205.util.MarqueeTextView
android:id="@+id/tv_runHorseLamp1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:singleLine="true"
android:text="这是一段很长的威武霸气的滚动的实现跑马灯效果的一段逼格很高的很有含义和涵养的文字"
/>
</LinearLayout>
popupwindow
public void onclick(view v){
String s[] = {"找回密码","短信验证码登录","邮箱/用户名登陆"};
AlertDialog Builder builder= new AlertDialog Builder(MainActivity this);
builder.setItems(s, new DialogInterface OnclickListenero{
@Verride
public void onclick(DialogInterface dialog, int which)
switch(which){
case 0:
break;
case 1:
break;
case 2:
break;
}
}
});
builder. show();