Can't get Actionbar Icon to animate - android

I'm trying to get my refresh button on my Actionbar to rotate, but I'm having some trouble getting it to work. The View just seems to lose it's horziontal margin/padding (which I haven't set anywhere), and does not rotate. I get no null errors, crashes, or anything else that could point me in the right direction. What am I doing wrong? Any help would be much apreciated.
Main.java:
public class Main extends ActionBarActivity{
...
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
refresh();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
public void refresh() {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView imageView = (ImageView) inflater.inflate(R.layout.action_refresh, null);
Animation rotation = AnimationUtils.loadAnimation(this, R.anim.rotate);
rotation.setRepeatCount(Animation.INFINITE);
imageView.startAnimation(rotation);
MenuItem item = menu.findItem(R.id.action_refresh);
item.setActionView(R.layout.action_refresh);
}
}
Menu.XML
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item android:id="#+id/action_refresh"
android:icon="#drawable/ic_action_refresh"
android:title="refresh"
android:actionLayout="#layout/action_refresh"
yourapp:showAsAction="ifRoom"
/>
<item
android:id="#+id/category_spinner_item"
android:showAsAction="ifRoom"
android:actionLayout="#layout/action_sort"
/>
</menu>
action_refresh.xml
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_refresh"
/>
anim/rotate.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="10000"
android:interpolator="#android:anim/linear_interpolator" />

Just change this line:
item.setActionView(R.layout.action_refresh);
To this:
MenuItemCompat.setActionView(item, imageView);
The reason it doesn't animate with the original line is because you are setting the action view to the static image resource, not the imageView that you set up to animate.

Related

Android Imageview Rotate Animation in NavigationView

I want to apply Animation in my Image View inside Navigation View.
I saw its working fine in some other apps. I have tried with following code but its not working for me.
drawer_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_logout"
android:icon="#drawable/ic_logout"
android:title="#string/nav_menu_logout" />
</group>
<group
android:id="#+id/menu_sync"
android:checkableBehavior="single">
<item
android:id="#+id/nav_sync_now"
android:title="#string/string_menu_sync_now"
app:actionLayout="#layout/layout_menu_sync_now"
app:showAsAction="always" />
</group>
</menu>
NavigationActivity.java
runOnUiThread(new Runnable() {
#Override
public void run() {
MenuItem menuItemSync = navigationBinding.navView.getMenu().findItem(R.id.nav_sync_now);
menuItemSync.setEnabled(false);
menuItemSync.setTitle(R.string.string_menu_syncing);
mImageViewSyncing = (AppCompatImageView) menuItemSync.getActionView().findViewById(R.id.nav_sync_now_image_view);
mImageViewSyncing.setColorFilter(ContextCompat.getColor(mContext, R.color.colorAccent));
/* Create Animation */
Animation mRotateAnimation = AnimationUtils.loadAnimation(mContext, R.anim.button_rotate);
/* start Animation */
mImageViewSyncing.startAnimation(mRotateAnimation);
}
});
button_rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<rotate
android:duration="2500"
android:interpolator="#android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="0"
android:fromDegrees="360"/>
</set>
layout_menu_sync_now.xml
<android.support.v7.widget.AppCompatImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/nav_sync_now_image_view"
android:layout_width="24dp"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:layout_gravity="end|center_vertical"
app:srcCompat="#drawable/ic_sync_black" />
Is there any suggestion what to do?
Thanks in advance.

Drawer layout with two navigation views and selected item colours

I have a drawer layout that needs to have two navigation views in it, because there's a couple of options that need to be aligned on top and another on the bottom, with a divider separating them.
I've managed to make it work, but now I have two different problems with my setup.
1) The first one, I can't change the selected items text color (the background color works as intented via a drawer selector, but for some reason, the selected item's text color is always colorPrimary)
2) The second one is trickier, since there's two navigation views, it can happen that there's a selected row on the first and on the second one, even though they all work loading fragments in the same container. Is there a way to manage that, when an item for the first navigation view is selected, the second navigation view's selected item gets deselected?
This is the drawer's layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- 1º Layout de la activity -->
<include layout="#layout/activity_main"/>
<!-- 2º Layout del drawer -->
<android.support.design.widget.NavigationView
android:id="#+id/container_navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:itemBackground="#drawable/drawer_list_selector"
android:nestedScrollingEnabled="true"
android:scrollIndicators="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/divider_height"
android:background="#color/colorAccent"
android:layout_above="#+id/navigation_view"
android:id="#+id/top_separator"/>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_above="#+id/bottom_separator"
app:itemBackground="#drawable/drawer_list_selector"
app:menu="#menu/menu_navigation" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/divider_height"
android:background="#color/colorAccent"
android:layout_above="#+id/navigation_bottom"
android:id="#+id/bottom_separator"/>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:menu="#menu/menu_navigation_bottom"
app:itemBackground="#drawable/drawer_list_selector"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
This is the top navigation view's layout:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_tus_ofertas"
android:title="#string/tus_ofertas"
android:icon="#drawable/ic_offer" />
<item
android:id="#+id/nav_movimiento_puntos"
android:title="#string/movimiento_puntos"
android:icon="#drawable/ic_points"/>
<item
android:id="#+id/nav_asociaciones"
android:title="#string/asociaciones"
android:icon="#drawable/ic_flag"/>
</group>
</menu>
Bottom navigation view's layout:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_terminos"
android:title="#string/terminos"
android:icon="#drawable/ic_document" />
<item
android:id="#+id/nav_contacto"
android:title="#string/contacto"
android:icon="#drawable/ic_email"/>
<item
android:id="#+id/nav_valorar"
android:title="#string/valorar"
android:icon="#drawable/ic_rate_review"/>
<item
android:id="#+id/nav_exit"
android:title="#string/exit"
android:icon="#drawable/ic_shutdown"/>
</group>
</menu>
Selected item's background selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="#color/colorAccent" />
<item android:state_activated="true" android:drawable="#color/colorAccent" />
<item android:state_selected="true" android:drawable="#color/colorAccent" />
<item android:state_checked="true" android:drawable="#color/colorAccent" />
<item android:state_pressed="false" android:drawable="#android:color/transparent" />
<item android:state_activated="false" android:drawable="#android:color/transparent" />
<item android:state_selected="false" android:drawable="#android:color/transparent" />
<item android:state_checked="false" android:drawable="#android:color/transparent" />
</selector>
The activity that calls the drawer and handles the events:
public class MainActivity extends AppCompatActivity {
#Bind(R.id.toolbar) Toolbar toolbar;
#Bind(R.id.tabs) TabLayout tabs;
#Bind(R.id.drawer_layout) DrawerLayout drawerLayout;
#Bind(R.id.container_navigation) NavigationView containerNavigator;
#Bind(R.id.navigation_view) NavigationView navigationView;
#Bind(R.id.navigation_bottom) NavigationView navigationBottom;
#Bind(R.id.vsFooter) ViewStubCompat stub;
ImageView userPicture;
TextView userMail;
ViewPager viewPager;
Menu menu;
ActionBar actionBar;
ViewPagerFragment viewPagerFragment;
Usuario currentUser;
public Usuario getCurrentUser() {
return currentUser;
}
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_drawer);
ButterKnife.bind(this);
currentUser = UserApiManager.getInstance(getApplicationContext()).getCurrentUser();
viewPagerFragment = ViewPagerFragment.newInstance();
setupToolbar();
setupNavigationDrawer();
ApiManager.getInstance(getApplicationContext()).setupFooter(stub, currentUser.getIdLocalidad(), this);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,viewPagerFragment).commit();
}
public void setupViewPager(ViewPager viewPager) {
tabs.setupWithViewPager(viewPager);
}
private void setupToolbar() {
setSupportActionBar(toolbar);
actionBar = getSupportActionBar();
if (actionBar!=null){
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_black);
actionBar.setTitle(getString(R.string.app_title));
}
}
private void setupNavigationDrawer() {
View headerView = navigationView.inflateHeaderView(R.layout.navigation_header);
userPicture = (ImageView) headerView.findViewById(R.id.user_picture);
userMail = (TextView) headerView.findViewById(R.id.user_mail);
userMail.setText(currentUser.getEmail());
Picasso.with(this).load(currentUser.getImagenURL()).transform(new CircleTransformation()).into(userPicture);
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.nav_tus_ofertas:
showTabLayout();
actionBar.setTitle(getString(R.string.app_title));
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,viewPagerFragment).commit();
break;
case R.id.nav_movimiento_puntos:
hideTabLayout();
Bundle bundle = new Bundle();
bundle.putString("idcliente", currentUser.getId());
MovimientoPuntosFragment movimientoPuntosFragment = MovimientoPuntosFragment.newInstance();
movimientoPuntosFragment.setArguments(bundle);
actionBar.setTitle(getString(R.string.movimiento_puntos));
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, movimientoPuntosFragment).commit();
break;
case R.id.nav_asociaciones:
hideTabLayout();
actionBar.setTitle(getString(R.string.asociaciones));
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, AsociacionFragment.newInstance()).commit();
break;
}
drawerLayout.closeDrawers();
return true;
}
});
navigationBottom.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.nav_terminos:
hideTabLayout();
actionBar.setTitle(getString(R.string.terminos));
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout, LegalesFragment.newInstance()).commit();
break;
case R.id.nav_contacto:
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse("mailto:?subject=" + getString(R.string.contacto_email));
intent.setData(data);
startActivity(intent);
break;
case R.id.nav_valorar:
final String appPackageName = BuildConfig.APPLICATION_ID;
try {
Log.i("url", "market://details?id=" + appPackageName);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
break;
case R.id.nav_exit:
break;
}
drawerLayout.closeDrawers();
return true;
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_over, menu);
this.menu = menu;
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
drawerLayout.openDrawer(GravityCompat.START);
break;
case R.id.action_user:
Intent intent = new Intent(this, PerfilUsuarioActivity.class);
startActivity(intent);
break;
}
return super.onOptionsItemSelected(item);
}
public void hideTabLayout(){
tabs.setVisibility(View.GONE);
}
public void showTabLayout(){
tabs.setVisibility(View.VISIBLE);
}
}
Any help would be appreciated!
Thanks in advance!
Solved!
The problem with the color I solved it with a selector, it didn't work before because I had a syntax error (selector tag inside the main selector tag).
This is the color selector's code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FFFFFFFF" android:state_checked="true" />
<item android:color="#E6000000" android:state_checked="false"/>
</selector>
The second problem I solved it by programmatically deselecting the other navigationview's items onNavigationItemSelected.
This is the function I call:
public void deselectItems(NavigationView view){
int size = view.getMenu().size();
for (int i = 0; i < size; i++) {
view.getMenu().getItem(i).setChecked(false);
}
}
I know there must be a better way to solve the second problem, but this one worked.

ImageButton animation not applied to all states

I have an ImageButton whose image rotates with the device orientation so that the image/ button is always horizontal (note that the rotations is handled manually, not through the activity life-cycle).
This all works great, except when the user presses the button (state is pressed), the 90' rotation is lost temporarily.
Button Animation;
<rotate
xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="-90"
android:pivotX="50%"
android:pivotY="50%"
android:duration="200" android:fillAfter="true">
</rotate>
The image button drawable;
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="#drawable/btn_go_back_pressed" />
<item android:state_enabled="false"
android:drawable="#drawable/btn_go_back_disabled" />
<item android:drawable="#drawable/btn_go_back_normal" />
</selector>
Loading the animation;
AnimationUtils.loadAnimation(mContext, R.anim.button_rotate90);
And then when the device orientation changes;
case MessageQue.SET_TO_PORTRAIT:
inPortrait = true;
for (View ib : buttonsToAnimate) {
if (ib instanceof TextView) {
ib.startAnimation(cntPortraitAnim);
} else {
ib.startAnimation(btnPortraitAnim);
}
}
Does anyone have any ideas on why, and more importantly, how to fix it?
Excellent pointer Whitney - this solved visibility issues I was having as well.
All the above code has been replaced with;
case MessageQue.SET_TO_LANDSCAPE:
for (View ib : buttonsToAnimate) ib.animate().rotation(0).setDuration(200);
break;
case MessageQue.SET_TO_PORTRAIT:
for (View ib : buttonsToAnimate) ib.animate().rotation(-90).setDuration(200);
break;
Thanks.

Android action bar refresh animation - Repeated icon

I follow the answer from this question: link
But I get this on my app:
As you can see on the ActionBar's right side there are two refresh icons (they were actually rotating when I took the screenshot). But I just want one to be there. I'm quite sure the problem is one of them is the item from the Menu XML file and the other is the ImageView from the actionbar_inderterminate_progress.xml file.
Here is my menu.xml file:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.mypackage.android.design.appdesgin.MainActivity" >
<item android:id="#+id/action_search"
android:title="Search"
android:icon="#drawable/ic_action_search"
android:showAsAction="always"
android:actionViewClass="android.widget.SearchView"
android:visible="false" />
<item android:id="#+id/action_create_local_backup"
android:title="Search"
android:icon="#drawable/ic_action_new"
android:showAsAction="always"
android:visible="false" />
<item
android:id="#+id/action_refresh"
android:icon="#drawable/ic_menu_refresh"
android:showAsAction="always"
android:title="Refresh">
</item>
<TextView
android:id="#+id/status_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"/>
And here is my actionbar_inderterminate_progress.xml:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/indeterminate_progress"
style="#android:style/Widget.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/app_name"
android:src="#drawable/ic_menu_refresh" />
My animation XML file:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="1000"
android:interpolator="#android:anim/accelerate_decelerate_interpolator" />
And my java code:
#Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.main, menu);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_refresh:
refreshItem = item;
refresh();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void refresh() {
/* Attach a rotating ImageView to the refresh item as an ActionView */
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ImageView imageView = (ImageView) inflater.inflate(R.layout.refresh_button, null);
Animation rotation = AnimationUtils.loadAnimation(getActivity(), R.animator.rotate_refresh);
rotation.setRepeatCount(Animation.INFINITE);
imageView.startAnimation(rotation);
refreshItem.setActionView(imageView);
}
Can anyone point me where and what am I doing wrong to make it only display one animated refresh button?
I was inflating the refresh button two times, one in MyActivity class and the other one on the Fragment that requires the refresh button.

Animation Drawable not working in GingerBread

This question is already been asked,but i didn't find any suitable answers and so I'm posting the question.
I've a ProgressBar animation which has multiple images and loads these images like a progressbar. I'm able to run it successfully in 4.0 and higher versions but it doesn't work in 2.3.How to make it work in lower versions?
My Animation Drawable XML file
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false"
android:pivotX="50%"
android:pivotY="50%" >
<item android:drawable="#drawable/p1_wheel" android:duration="200"/>
<item android:drawable="#drawable/p2_wheel" android:duration="200"/>
<item android:drawable="#drawable/p3_wheel" android:duration="200"/>
<item android:drawable="#drawable/p4_wheel" android:duration="200"/>
<item android:drawable="#drawable/p5_wheel" android:duration="200"/>
<item android:drawable="#drawable/p6_wheel" android:duration="200"/>
<item android:drawable="#drawable/p7_wheel" android:duration="200"/>
<item android:drawable="#drawable/p8_wheel" android:duration="200"/>
<item android:drawable="#drawable/p9_wheel" android:duration="200"/>
<item android:drawable="#drawable/p10_wheel" android:duration="200"/>
<item android:drawable="#drawable/p11_wheel" android:duration="200"/>
<item android:drawable="#drawable/p12_wheel" android:duration="200"/>
</animation-list>
My XML File
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_centerInParent="true"/>
</RelativeLayout>
My Java File
package com.example.progressbarsample;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.DrawableContainer;
import android.view.Menu;
import android.widget.ImageView;
import android.widget.ProgressBar;
public class MainActivity extends Activity {
ImageView progressbar;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progressbar = (ImageView) findViewById(R.id.imageView1);
progressbar.setBackgroundResource(R.drawable.progressbar);
final AnimationDrawable frame = (AnimationDrawable) progressbar.getBackground();
progressbar.post(new Runnable() {
#Override
public void run() {
frame.start();
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
At Last I found a solution to this.
progressbar = (ImageView) findViewById(R.id.imageView1);
progressbar.setBackgroundResource(R.drawable.progressbar);
final AnimationDrawable frame = (AnimationDrawable)getResources.getDrawable(R.drawable.progressbar); \\progressbar is the anim.xml file
progressbar.setBackgroundDrawable(frame);
progressbar.post(new Runnable() {
#Override
public void run() {
frame.start();
}
});
}
try animating after the view is visible like this:
#Override
public void onWindowFocusChanged (bool hasFocus)
{
super.onWindowFocusChanged (hasFocus);
//get the animation from your view
AnimationDrawable explosionAnimation = (AnimationDrawable) mImageView.getBackground();
//set it visible and start animation
explosionAnimation.setVisible (true, true);
explosionAnimation.start ();
}
The method onWindowFocusChanged from Activity is called after the view is already visible and it gets the focus. So, you will be able to animate your image.
I've tried without setVisible but only a static image was shown. The same happens when I started the animation from onResume, onStart, etc.
The code above works fine for me, including Android 2.3. I'm currently working with mono (with Xamarin), but I hope it's gonna work for you in Java.
I have worked with Drawable Animations and it works for me here my Code:
mImageView.setBackgroundResource(R.drawable.anim);
AnimationDrawable explosionAnimation = (AnimationDrawable) mImageView.getBackground();
explosionAnimation.start();
But i think its becausse of the post, try the code without using the progressbar.post

Categories

Resources