文字跑马灯
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
//padding指当前视图与内部内容的距离 //orientation指定线性布局的方向 //horizontal(默认)表示水平布局,vertical垂直
//margin指当前视图与周围视图的距离
//gravity指定布局内部视图与本线性布局的对齐方式
/*layout_weight指定当前视图的宽或高占上级线性布局的权重, 当指定当前视图在宽度上占的权重,layout_width需设置为0dp; 高上占的权重时,layout_height需设置为0dp*/<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="20dp" android:gravity="center" android:text="跑马灯效果,点击暂停,再点击恢复"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tv_marquee" android:layout_marginTop="20dp" android:singleLine="true" android:ellipsize="marquee" android:focusable="false" android:focusableInTouchMode="true" android:textColor="#000000" android:textSize="17sp" android:text="快讯:红色预警,超强台风“莫兰蒂” 即将登陆,请居民关紧门窗、备足粮草,做好防汛救灾准备!"/>
//singelLine文字单行显示,focusable是否获得焦点,focusableInTouchMode指定触摸时是否获得焦点
//ellipsize指定文本超出范围后的显示方式,marquee跑马灯显示
</LinearLayout>