TextView文字横向自动滚动
2014-05-29 17:57
302 查看
效果截图:
:
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:gravity="center"
>
<TextView android:id="@+id/text1"
android:layout_width="80dp"
android:layout_height="40dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:scrollHorizontally="true"
android:focusableInTouchMode="true"
android:layout_centerInParent="true"
android:textColor="#0551A5"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:singleLine="true"/>
<!--android:focusable="true"是否获取焦点-->
<!--focusableInTouchMode:通过触摸获取焦点-->
<!--android:ellipsize="marquee"设置为跑马灯-->
<!--android:marqueeRepeatLimit="marquee_forever"滚动次数里面可以直接写数字-->
<!--marquee_forever表示永远滚动-->
<!--android:scrollHorizontally="true"水平滚动-->
<!--android:singleLine="true"单行输入-->
</LinearLayout>
Java代码:
package com.example.MargueeTextView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MyActivity extends Activity {
private TextView text1;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text1=(TextView)findViewById(R.id.text1);
text1.setText("春光无限好,只是近黄昏………………");
}
}
:
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:gravity="center"
>
<TextView android:id="@+id/text1"
android:layout_width="80dp"
android:layout_height="40dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:scrollHorizontally="true"
android:focusableInTouchMode="true"
android:layout_centerInParent="true"
android:textColor="#0551A5"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:singleLine="true"/>
<!--android:focusable="true"是否获取焦点-->
<!--focusableInTouchMode:通过触摸获取焦点-->
<!--android:ellipsize="marquee"设置为跑马灯-->
<!--android:marqueeRepeatLimit="marquee_forever"滚动次数里面可以直接写数字-->
<!--marquee_forever表示永远滚动-->
<!--android:scrollHorizontally="true"水平滚动-->
<!--android:singleLine="true"单行输入-->
</LinearLayout>
Java代码:
package com.example.MargueeTextView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MyActivity extends Activity {
private TextView text1;
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
text1=(TextView)findViewById(R.id.text1);
text1.setText("春光无限好,只是近黄昏………………");
}
}
源码下载地址
相关文章推荐
- Android TextView文字横向自动滚动(跑马灯)
- Android文字自动横向滚动的TextView(文字长度不够也可以)
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动…
- Android TextView文字横向自动滚动(跑马灯)
- adnroid textview设置文字横向自动滚动(跑马灯效果)
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- Android:TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- Android TextView文字横向自动滚动(跑马灯)
- TextView文字横向自动滚动(跑马灯)
- Android使用WebView加载文字总结之中文乱码、禁止横向滚动、自动换行
- 实现TextView的垂直滚动,更新文字时自动滚动到最后一行
- Android自定义TextView实现文字自动滚动
- Android 如何实现带滚动条的TextView,在更新文字时自动滚动到最后一行
- 实现TextView的垂直滚动,更新文字时自动滚动到最后一行
- TextView跑马灯效果,也就是,自动滚动文字的效果。