——————首先用shap画出小球,特别简单
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="50dp" /> <stroke android:color="#a44848" android:width="1dp" /> <solid android:color="#a44848" /> </shape>——————然后就是布局的代码,没有什么奇特的东西
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/text_view" android:layout_width="50dp" android:background="@drawable/bg_circle" android:layout_height="50dp" /> </RelativeLayout>——————当然最后就是我们的主页面了
public class WelcomeActivity extends AppCompatActivity { private TextView txtCircle; public static final int FLAG = 1; private Handler handler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (msg.what ==FLAG) { Intent intent=new Intent(WelcomeActivity.this,MainActivity.class); startActivity(intent); finish(); } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); txtCircle = findViewById(R.id.text_view); handler.sendEmptyMessageDelayed(FLAG,6000); //这个是你的模拟器的分辨率,是多少,大的那个就是长,小的就是宽 ObjectAnimator tyAnimator = ObjectAnimator.ofFloat(txtCircle, "translationY", 0, 1920); ObjectAnimator txAnimator = ObjectAnimator.ofFloat(txtCircle, "translationX", 0, 1080); txAnimator.setDuration(5000); txAnimator.start(); tyAnimator.setDuration(5000); tyAnimator.start(); } @Override protected void onDestroy() { super.onDestroy(); handler.removeCallbacksAndMessages(null); } }
