首页 > 其他 > 详细

跑马灯效果

时间:2015-02-26 20:03:53      阅读:289      评论:0      收藏:0      [点我收藏+]

activity类:

public class MainActivity extends Activity {

TextView text;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

text = (TextView)findViewById(R.id.textView1);
text.setText("用户名");
text.setTextColor(Color.RED);
text.setText(Html.fromHtml("Hellodfrasdfsdfdsa<font color = red>Worfasdfsadfasdfasdld</font>"));

/*SpannableString ss = new SpannableString("Hello World");
ss.setSpan(new BackgroundColorSpan(Color.BLUE),0, 5, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
text.setText(ss);*/
}

@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;
}

}

 

XML文件:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:textSize="50dp"
/>


</LinearLayout>

跑马灯效果

原文:http://www.cnblogs.com/Smart-Du/p/4301967.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!