其他分享
首页 > 其他分享> > Android Studio实现最简单走马灯

Android Studio实现最简单走马灯

作者:互联网

效果展示,嗷呜~~
在这里插入图片描述
下面展示 XML码片

<TextView
    android:id="@+id/tv1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="实现最简单走马灯"
    android:textSize="28sp"
    android:layout_gravity="center"
    android:drawablePadding="4dp"
    />
<TextView android:layout_marginTop="20dp"
    android:id="@+id/tv3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="山有木兮木有枝,心悦君兮君不知!           山有木兮木有枝,心悦君兮君不知!"
    android:textColor="#0000ff"
    android:textSize="20dp"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusable="true"
    android:focusableInTouchMode="true"
    />
<TextView android:layout_marginTop="20dp"
    android:id="@+id/tv2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="古诗"
    android:textSize="20dp"
    android:gravity="right"
    android:shadowColor="#0000ff"
    android:shadowRadius="3"
    android:shadowDx="15"
    android:shadowDy="15"
    />
<TextView
    android:layout_marginTop="30dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="      天涯也有江南信,梅破知春近。夜阑风细得香迟,不道晓来开遍向南枝。"
    android:textSize="20sp"
    />
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="      玉台弄粉花应妒,飘到眉心住。平生个里愿怀深,去国十年老尽少年心。"
    android:textSize="20sp"
    />

以及JAVA代码

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.introduction_layout);
    
    TextView tv3=findViewById(R.id.tv3);
    tv3.setSelected(true);

    
    TextView tv1=(TextView)findViewById(R.id.tv1);
    Drawable drawable=getResources().getDrawable(R.drawable.tou11);
    drawable.setBounds(0,0,130,130);
    tv1.setCompoundDrawables(drawable,null,null,null);
}

标签:tv1,tv3,130,Studio,走马灯,Android,null,drawable,TextView
来源: https://blog.csdn.net/qq_43510316/article/details/106457107