use of com.wnafee.vector.MorphButton in project vector-compat by wnafee.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Example of adding MorphButton in java
MorphButton mb = new MorphButton(this);
LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
mb.setLayoutParams(p);
mb.setBackgroundTintList(getResources().getColorStateList(R.color.background_tint_color));
mb.setForegroundTintList(getResources().getColorStateList(R.color.foreground_tint_color));
mb.setStartDrawable(R.drawable.ic_pause_to_play);
mb.setEndDrawable(R.drawable.ic_play_to_pause);
mb.setOnStateChangedListener(new OnStateChangedListener() {
@Override
public void onStateChanged(MorphState changedTo, boolean isAnimating) {
// Do something here
Toast.makeText(MainActivity.this, "Changed to: " + changedTo, Toast.LENGTH_SHORT).show();
}
});
LinearLayout ll = (LinearLayout) findViewById(R.id.base_view);
ll.addView(mb);
}
Aggregations