TextView实现跑马灯效果
发布时间:2020-12-15 00:17:56 所属栏目:Java 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_widt
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 <RelativeLayout 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" tools:context="com.example.t.MainActivity" > <TextView android:id="@+id/notice" android:layout_width="fill_parent" android:layout_height="fill_parent" android:ellipsize="marquee"//以横向滚动方式显示(需获得当前焦点时) android:focusable="true"//允许获取焦点 android:focusableInTouchMode="true"//设置是否触摸模式。 android:gravity="center" android:marqueeRepeatLimit="marquee_forever"//一直滚动 android:scrollHorizontally="true"//设置文本超出TextView长度的情况下,是否出现横拉条 android:singleLine="true"//单行显示 android:textSize="20sp" android:textColor="#FF0000" android:text="回收二手航母、导弹、潜艇、坦克、翻新原子弹啦!!!!..." android:textStyle="bold" /> </RelativeLayout> JAVA代码:MainActivity.java package com.example.t; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.Window; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);//无标题 setContentView(R.layout.activity_main); } @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; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button,so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } 以上内容由PHP站长网【52php.cn】收集整理供大家参考研究 如果以上内容对您有帮助,欢迎收藏、点赞、推荐、分享。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |