//这里返回的TextView,就是我们看到的View,可以设置自己想要的效果
public View makeView() {
TextView textView = new TextView(mContext);
textView.setGravity(Gravity.LEFT);
textView.setTextSize(20);
textView.setSingleLine(true);
textView.setGravity(Gravity.CENTER_VERTICAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setTextColor(Color.WHITE);
return textView;
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--左右滚动的textview--> <www.autotextview.com.autotextview.View.AutoHorizontalScrollTextView android:textSize="20sp" android:background="#000000" android:textColor="#ffffff" android:id="@+id/textview" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" /> <!--上下滚动的TextView--> <www.autotextview.com.autotextview.View.AutoVerticalScrollTextView android:id="@+id/textview_auto_roll" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#000000" android:padding="5dp" /> </LinearLayout>
horizontalScrollTV = (AutoHorizontalScrollTextView) findViewById(R.id.textview); horizontalScrollTV.setText(titleStr);
private String[] strings={"我的剑,就是你的剑!","俺也是从石头里蹦出来得!","我用双手成就你的梦想!","人在塔在!","犯我德邦者,虽远必诛!","我会让你看看什么叫残忍!","我的大刀早已饥渴难耐了!"};
verticalScrollTV = (AutoVerticalScrollTextView) findViewById(R.id.textview_auto_roll);
verticalScrollTV.setText(strings[0]);
new Thread(){
@Override
public void run() {
while (isRunning){
SystemClock.sleep(3000);
handler.sendEmptyMessage(199);
}
}
}.start();
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
if (msg.what == 199) {
verticalScrollTV.next();
number++;
verticalScrollTV.setText(strings[number%strings.length]);
}
}
};
verticalScrollTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this,strings[number%strings.length],Toast.LENGTH_SHORT).show();
}
});
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有