Friday, November 27, 2015

Android - How change the background color of the Action Bar

It is easy to change the background color of the Action Bar without modify style xml.
You can change the background color by below code.
 // Change the background color into red.
 getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFFFF0000));

Example : 
[Before to change color]



[After to change color]

[Full Source]
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
public class ActionBarTestActivity extends ActionBarActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_action_bar_test);
        // Change the background color into red.
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFFFF0000));
    }
}


Thursday, November 26, 2015

Creating Swipe Views of Android App with Tabs

1. Create a New Android Project.

2. Input the Application Name & Company Domain and click the Next button.


3. Select the Minimum SDK and click the Next button.



4. Select the Tabbed Activity and click the Next button.


5. Select the Action Bar Tabs(with ViewPager) on the Navigation Style and click the Finish button.



6. If below errors occurs while building Android Project, you have to change appcompat version 23.1.1 into 22.1.1.
  (If your project SDK version is over 23, you can build new project without errors.)