首先需要已经安装好了Andorid Studio并且配置好了虚拟手机并能够运行开机。
创建一个project

选empty即可

点击next

自己调整项目路径
注意不要出现中文
这里Android选择5.0说可以支持大概98.8%的设备,蛮多了。
点击finish完成创建
然后他会自己下载配置文件,需要联网耐心等待。
下载完成后

点击project选择project可以展现工程的全部文件
点击Android就展现
Android目录下的文件


主要用户来放需要的java类

layout放置布局文件

values放颜色、文字、样式等配置文件。
配置文字
<resources>
<string name="app_name">Hunter Worldstring>
<string name="tv_one">ICY Hunter ICY Hunter ICY Hunter ICY Hunterstring>
resources>
配置颜色
<resources>
<color name="purple_200">#FFBB86FCcolor>
<color name="purple_500">#FF6200EEcolor>
<color name="purple_700">#FF3700B3color>
<color name="teal_200">#FF03DAC5color>
<color name="teal_700">#FF018786color>
<color name="black">#FF000000color>
<color name="white">#FFFFFFFFcolor>
resources>
配置布局文件
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/tv_one"
android:layout_width="match_parent"
android:layout_height="282dp"
android:text="@string/tv_one"
android:textColor="@color/black"
android:textStyle="normal"
android:textSize="100sp"
android:background="@color/purple_200"
android:layout_gravity="center_vertical"
android:shadowColor="@color/purple_700"
android:shadowRadius="3.0"
android:shadowDx="15.0"
android:shadowDy="10.0"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
>
<requestFocus/>
TextView>
LinearLayout>

点击运行app
然后虚拟机就会出现如下:

出现滚动的带阴影的跑马灯的效果。
对代码进行如下添加和修改:
main/java的保重创建一个java类(MyTextView)

MyTextView:
package com.example.hunter;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
import androidx.annotation.Nullable;
public class MyTextView extends TextView {
public MyTextView(Context context) {
super(context);
}
public MyTextView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public boolean isFocused() {
return true;
}
}
用上自己写的类
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.hunter.MyTextView
android:id="@+id/tv_one"
android:layout_width="match_parent"
android:layout_height="282dp"
android:text="@string/tv_one"
android:textColor="@color/black"
android:textStyle="normal"
android:textSize="100sp"
android:background="@color/purple_200"
android:layout_gravity="center_vertical"
android:shadowColor="@color/purple_700"
android:shadowRadius="3.0"
android:shadowDx="15.0"
android:shadowDy="10.0"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:clickable="true"
/>
</LinearLayout>

然后点击重新运行
出现一样的效果。
https://www.bilibili.com/video/BV1Jb4y187C4?p=10&spm_id_from=pageDriver