Closed shrenikm closed 9 years ago
Hi, There is nothing wrong with the code you are using:
actionButton.setShowAnimation(getResources().getAnimation(R.anim.fab_fade_in));
actionButton.setShowAnimation(ActionButton.Animations.FADE_IN);
and actually it works well in the demo application.
Please provide the full code example, which contains the ActionButton object instantiation, setting the animation type and forcing its playing. Also, provide the version, which you are using
I'm using android version 4.0.4
Heres the code:
package --------------------------;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import com.software.shell.fab.ActionButton;
public class MainActivity extends ActionBarActivity {
ActionButton mActionButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mActionButton = (ActionButton)findViewById(R.id.action_button);
mActionButton.setButtonColor(getResources().getColor(R.color.app_theme_blue));
mActionButton.setButtonColorPressed(getResources().getColor(R.color.app_dark_theme_blue));
// The error is caused in the following statement.
mActionButton.setShowAnimation(getResources().getAnimation(R.anim.fab_fade_in));
mActionButton.setShowAnimation(ActionButton.Animations.FADE_IN);
mActionButton.playShowAnimation();
// The following code is for the listview fragment. It works properly
if(findViewById(R.id.fragment_container)!=null)
{
if(savedInstanceState!=null)
{
return;
}
GeneralListFragment generalListFragment = new GeneralListFragment();
generalListFragment.setArguments(getIntent().getExtras());
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, generalListFragment).commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Why are you setting showAnimation twice? You can choose between either of these 2 methods that you are using
You mean either
mActionButton.setShowAnimation(getResources().getAnimation(R.anim.fab_fade_in));
or
mActionButton.setShowAnimation(ActionButton.Animations.FADE_IN); ?
I tried running only mActionButton.setShowAnimation(ActionButton.Animations.FADE_IN); but it didnt work.
Post a stacktrace here please
It's resolved now. I thought that the animation would take place automatically when I scrolled. Just realised that it works if I implement my scroll listeners. My bad.
Thanks :D
Great
Hi,
Its a great library that you've made. It helped a lot :)
But when I tried to set the animation to the button using :
actionButton.setShowAnimation(getResources().getAnimation(R.anim.fab_fade_in)); actionButton.setShowAnimation(ActionButton.Animations.FADE_IN);
it throws an error saying cannot resolve method setShowAnimation(android.content.res.xmlResourseParser)
I guess I'm not implementing it correctly. Any help would be appreciated.
(I'm using android api level 15)