Ich möchte nur meine Bild-Taste, um die Skala zu machen (wenig Zoom in & out repeted) Animation, wenn die App startet, auf dem ersten Bildschirm, bis ich es drücke. Das liegt daran, dass dies der "wichtigste" und der wichtigste Button der App ist und ich möchte die Aufmerksamkeit des Nutzers auf sich ziehen. Ich habe einige Tutorials gefunden und ich erreichte so weit:Android Button Scale Animation
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>
Button-xml in 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"
/>
Bitte helfen :(
ps: ich Neuling bin, das ist meine erste App
sehen Sie die Änderungen, die ich an der MainScreen.java vorgenommen habe. Es gibt mir Fehler zu ** (Button) findViewById (R.id.ImageButton); ** und ** btn.startAnimation (Skala); ** –
sollten Sie Maßstab gloabal machen ... auch die Schaltfläche .... – Timo
müssen Sie die endgültige Animation vor der Skalierung entfernen .... – Timo