自定義一個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>
dialog
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();