最初の画面でアプリを起動するときに、私が押し込むまで、スケール(少し拡大して&の小さなズーム)アニメーションを行いたいだけです。これはアプリの「メイン」ボタンと最も重要なボタンなので、ユーザーの注目を集めたいからです。私はいくつかのチュートリアルを発見したと私はこれまでのところ達し:Androidボタンスケールのアニメーション
MainScreen.java
package com.example.konarx.a11042016;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
public class MainScreen extends AppCompatActivity {
private Button btn;
final Animation scale; //ERROR - Variable 'scale' might not have been initialized//
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_screen);
final scale = AnimationUtils.loadAnimation(this, R.anim.gps_button_animation); //ERROR - Unknown class: 'scale'//
btn = (Button) findViewById(R.id.ImageButton); //ERROR - Unexpected cast to `Button`: layout tag was `ImageButton`//
btn.startAnimation(scale); //I just want to do the animation without clicking it. Is that going to work?//
}
public void InfoActivity(View view) {
Intent intent = new Intent(this, InfoActivity.class);
startActivity(intent);
}
}
gps_button_animation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale
android:fromXScale="1.0"
android:toXScale="3.0"
android:fromYScale="1.0"
android:toYScale="3.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="500"
android:repeatCount="1"
android:repeatMode="reverse" />
</set>
ボタンXML main_activity.xlmで
<ImageButton
android:id="@+id/ImageButton"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="@drawable/button_image"
android:layout_marginTop="15dp"
/>
:(
がPS助けてください:さて、あなたはこのボタンを設定する必要があり、私は、これが私の最初のアプリ
MainScreen.javaの変更点を確認してください。それは私にエラーを与えます **(ボタン)findViewById(R.id.ImageButton); **と** btn.startAnimation(スケール); ** –
あなたはスケールgloobal ...ボタンを作る必要があります.... – Timo
スケールの最後のアニメーションを削除する必要があります。 – Timo