J'ai créé une application, qui utilise InfiniteViewpager par antonyt.Fragment Android Oncreateview Loadanimation
Je veux ajouter une animation sur un Imageview
lorsque ma vue est créée, mais mon animation fonctionne plusieurs fois, pas toujours. Voici le code:
public class ColourFragment extends Fragment {
private int identifier;
private String logo;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
identifier = args.getInt("identifier");
logo = args.getString("logo");
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.radiologok, container, false);
Le ImageView
Je veux animer.
ImageView imageView = (ImageView)V.findViewById(R.id.radiologovalaszto);
ProgressBar progressBar = (ProgressBar) V.findViewById(R.id.progressBar1);
DisplayMetrics displaymetrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels/4 * 3;
int width = displaymetrics.widthPixels/4 * 3;
imageView.setAdjustViewBounds(true);
imageView.getLayoutParams().height = height;
imageView.getLayoutParams().width = width;
Charger la bibliothèque de requêtes Android pour obtenir une image à partir du Web.
AQuery aq = new AQuery(getActivity());
AQUtility.setDebug(true);
aq.hardwareAccelerated11();
L'image est définie.
aq.id(imageView).progress(progressBar).image(logo, true, true, width, 0);
Ici, je veux ajouter le Animation
Animation pulse = AnimationUtils.loadAnimation(getActivity(), R.anim.pulse);
imageView.startAnimation(pulse);
Return V;
}
Voici mon animation:
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" />
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="1000"
android:toXScale="2"
android:toYScale="2" />
</set>
que je charge la vue en utilisant un fragmentadapter:
final PagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public int getCount() {
return Radiologos.length;
}
@Override
public Fragment getItem(int position) {
Fragment fragment = new ColourFragment();
Bundle args = new Bundle();
args.putString("logo", Radiologos[position]);
args.putInt("identifier", position);
fragment.setArguments(args);
return fragment;
}
};
réutilisez-vous la vue ? Est-ce dans n'importe quelle liste? –
C'est dans un fragment. – user2617730
Mais où montrez-vous ce fragment? dans la liste ou Activité ou Viewpager, et s'il vous plaît poster le code où vous l'utilisez –