注意不要出现中文
这里Android选择5.0说可以支持大概98.8%的设备,蛮多了。
点击finish完成创建
然后他会自己下载配置文件,需要联网耐心等待。
下载完成后
点击project选择project可以展现工程的全部文件
点击Android就展现
Android目录下的文件
配置文件简介
主要用户来放需要的java类
layout放置布局文件
values放颜色、文字、样式等配置文件。
阴影走马灯文字
values/string.xml
配置文字
<resources>
<string name="app\_name">Hunter World</string>
<string name="tv\_one">ICY Hunter ICY Hunter ICY Hunter ICY Hunter</string>
</resources>
values/colors.xml
配置颜色
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple\_200">#FFBB86FC</color>
<color name="purple\_500">#FF6200EE</color>
<color name="purple\_700">#FF3700B3</color>
<color name="teal\_200">#FF03DAC5</color>
<color name="teal\_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
layout/activity_main.xml
配置布局文件
<?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">
<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
然后虚拟机就会出现如下:
出现滚动的带阴影的跑马灯的效果。
法2
对代码进行如下添加和修改:
main/java
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;
}
}
layout/activity_main.xml
用上自己写的类
<?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>
然后点击重新运行
出现一样的效果。