We are often logged in some android apps, as an android developer we must be curious with the interface of the instagram application where the background can change its color with a very good time, therefore "Captain Code" provides a solution for you who want to know how to make a background like login on instagram that change its color automatically and periodically.
Screenshot
Source Code
Videos
Code Sample
- MainActivity.xml
package captain.code; import android.graphics.drawable.AnimationDrawable; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.widget.FrameLayout; public class MainActivity extends AppCompatActivity { AnimationDrawable animationDrawable; FrameLayout frameLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); //Declare Animation and FrameLayout frameLayout = (FrameLayout)findViewById(R.id.myFrameLay); animationDrawable =(AnimationDrawable)frameLayout.getBackground(); //Add time changes animationDrawable.setEnterFadeDuration(5000); animationDrawable.setExitFadeDuration(2000); //And start the animation Now animationDrawable.start(); //Thanks For Watching dont forget for Subscribe } @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); } }Welcome Developers.
EmoticonEmoticon