Example usage for android.app ActionBar setStackedBackgroundDrawable

List of usage examples for android.app ActionBar setStackedBackgroundDrawable

Introduction

In this page you can find the example usage for android.app ActionBar setStackedBackgroundDrawable.

Prototype

public void setStackedBackgroundDrawable(Drawable d) 

Source Link

Document

Set the ActionBar's stacked background.

Usage

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void applyActionBarBackground(final ActionBar actionBar, final Context context,
        final int themeRes) {
    if (actionBar == null || context == null)
        return;//w ww.j a  v a 2s.  co  m
    actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes));
    actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
    actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static void applyActionBarBackground(final ActionBar actionBar, final Context context,
        final boolean applyAlpha) {
    if (actionBar == null || context == null)
        return;//  www.  jav a2 s  .c  o m
    actionBar.setBackgroundDrawable(getActionBarBackground(context, applyAlpha));
    actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, applyAlpha));
    actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, applyAlpha));
}

From source file:za.ac.uct.cs.lwsjam005.eshelf.activities.ReadActivity.java

private void setupActionBar() {
    ActionBar actionBar = getActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);

    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));
    actionBar.setSplitBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));

    actionBar.setIcon(thisBook.getIcon());
    actionBar.setTitle(thisBook.getTitle());
    actionBar.setSubtitle(thisBook.getAuthor());

}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void applyActionBarBackground(final ActionBar actionBar, final Context context,
        final int themeRes, final int actionBarColor) {
    if (actionBar == null || context == null)
        return;/*from  w w w.ja  v a2  s. com*/
    actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes, actionBarColor));
    actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
    actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static void applyActionBarBackground(final android.support.v7.app.ActionBar actionBar,
        final Context context, final int themeRes, final int actionBarColor) {
    if (actionBar == null || context == null)
        return;/*from  w w  w  . j  a va2s .  co  m*/
    actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes, actionBarColor));
    actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
    actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static void applyActionBarBackground(final ActionBar actionBar, final Context context,
        final int themeRes, final int accentColor, boolean outlineEnabled) {
    if (actionBar == null || context == null)
        return;/*from ww w.j a  v a2s  .c o  m*/
    actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes, accentColor, outlineEnabled));
    actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
    actionBar.setStackedBackgroundDrawable(
            getActionBarBackground(context, themeRes, accentColor, outlineEnabled));
}

From source file:com.example.swipeuiforupclose.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile_main);

    // Create the adapter that will return a fragment for each of the three
    // primary sections
    // of the app.

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is
    // no hierarchical
    // parent./*from ww  w .j  a va  2 s .c om*/
    actionBar.setHomeButtonEnabled(false);
    actionBar.setBackgroundDrawable(new ColorDrawable(0xFF46304e));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(0xFF573d5d));
    actionBar.setTitle("My Profile");

    // Specify that we will be displaying tabs in the action bar.
    //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // Set up the ViewPager, attaching the adapter and setting up a listener
    // for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select
            // the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if
            // we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter.
        // Also specify this Activity object, which implements the
        // TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:org.getlantern.firetweet.util.ThemeUtils.java

public static void applyActionBarBackground(final android.support.v7.app.ActionBar actionBar,
        final Context context, final int themeRes, final int accentColor, boolean outlineEnabled) {
    if (actionBar == null || context == null)
        return;//from  www .  j a v a2 s . co  m
    actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes, accentColor, outlineEnabled));
    actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
    actionBar.setStackedBackgroundDrawable(
            getActionBarStackedBackground(context, themeRes, accentColor, outlineEnabled));
}

From source file:com.xenon.greenup.MainActivity.java

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent.
    actionBar.setHomeButtonEnabled(false);

    //Set the stacked background otherwise we get the gross dark gray color under the icon
    BitmapDrawable background = (BitmapDrawable) getResources().getDrawable(R.drawable.bottom_menu);
    background.setTileModeXY(TileMode.REPEAT, TileMode.MIRROR);
    actionBar.setStackedBackgroundDrawable(background);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setIcon(R.drawable.bottom_menu);

    _ViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, _ViewPager);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < 3; i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.

        ActionBar.Tab tabToAdd = actionBar.newTab();
        if (i == 0)
            //Set the home page as active since we'll start there:
            tabToAdd.setIcon(getActiveIcon(i));
        else/*  w  w  w .j a  v  a  2  s . co m*/
            tabToAdd.setIcon(getRegularIcon(i));
        mTabsAdapter.addTab(tabToAdd);

    }

    //Setting the display to custom will push the action bar to the top
    //which gives us more real estate
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.show();
    Log.i("visible", "" + _ViewPager.VISIBLE);

}

From source file:com.inc.playground.playgroundApp.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    globalVariables = ((GlobalVariables) getApplication());
    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    setPlayGroundActionBar();//from w  w w .ja v a  2s  . c  o  m
    //set actionBar color
    actionBar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.primaryColor)));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.secondaryColor)));
    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.
    //actionBar.setHomeButtonEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(actionBar.newTab().setTabListener(this));
    }
    actionBar.getTabAt(0).setIcon(R.drawable.pg_list_view);
    actionBar.getTabAt(1).setIcon(R.drawable.pg_map_view);
    //NavigationDrawer handling (e.g the list from leftside):
    mTitle = mDrawerTitle = getTitle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.menu_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.pg_menu, /* nav drawer icon to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description */
            R.string.drawer_close /* "close drawer" description */
    ) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            getActionBar().setTitle(mTitle);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getActionBar().setTitle(mDrawerTitle);
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.closeDrawers();
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // all linear layout from slider menu

    /*Home button */
    LinearLayout ll_Home = (LinearLayout) findViewById(R.id.ll_home);
    ll_Home.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // new changes
            Intent iv = new Intent(MainActivity.this, MainActivity.class);
            startActivity(iv);
            finish();
        }
    });
    /*Login button */
    LinearLayout ll_Login = (LinearLayout) findViewById(R.id.ll_login);
    ll_Login.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // new changes
            LinearLayout ll_Login = (LinearLayout) v;
            TextView loginTxt = (TextView) findViewById(R.id.login_txt);
            if (loginTxt.getText().equals("Login")) {
                Intent iv = new Intent(MainActivity.this, Login.class);
                startActivity(iv);
                finish();
            } else if (loginTxt.getText().equals("Logout")) {
                final Dialog alertDialog = new Dialog(MainActivity.this);
                alertDialog.setContentView(R.layout.logout_dilaog);
                alertDialog.setTitle("Logout");
                alertDialog.findViewById(R.id.ok_btn).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
                        SharedPreferences.Editor editor = prefs.edit();
                        editor.clear();
                        editor.commit();
                        ImageView loginImg = (ImageView) findViewById(R.id.login_img);
                        TextView loginTxt = (TextView) findViewById(R.id.login_txt);
                        loginTxt.setText("Login");
                        loginImg.setImageResource(R.drawable.pg_action_lock_open);

                        globalVariables = ((GlobalVariables) getApplication());
                        globalVariables.SetCurrentUser(null);
                        globalVariables.SetUserPictureBitMap(null);
                        globalVariables.SetUsersList(null);
                        globalVariables.SetUsersImagesMap(null);

                        Util.clearCookies(getApplicationContext());

                        Intent iv = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(iv);
                        finish();
                    }
                });

                alertDialog.findViewById(R.id.cancel_btn).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        Intent iv = new Intent(MainActivity.this, MainActivity.class);
                        startActivity(iv);
                        finish();
                    }
                });

                alertDialog.show(); //<-- See This!
            }

        }
    });
    //
    //        /*Setting button*/
    //        LinearLayout ll_Setting = (LinearLayout) findViewById(R.id.ll_settings);
    //        ll_Setting.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                // TODO Auto-generated method stub
    //                // new changes
    //                Intent iv = new Intent(MainActivity.this,
    //                        com.inc.playground.playgroundApp.upLeft3StripesButton.
    //                                SettingsActivity.class);
    //                startActivity(iv);
    //                finish();
    //            }
    //        });

    /*My profile button*/
    LinearLayout ll_my_profile = (LinearLayout) findViewById(R.id.ll_my_profile);
    ll_my_profile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // new changes
            globalVariables = ((GlobalVariables) getApplication());
            User currentUser = globalVariables.GetCurrentUser();
            if ((currentUser == null) || (currentUser != null && currentUser.GetUserId() == null)) {
                Toast.makeText(MainActivity.this, "You are not logged in", Toast.LENGTH_LONG).show();
            } else {

                Intent iv = new Intent(MainActivity.this,
                        com.inc.playground.playgroundApp.upLeft3StripesButton.MyProfile.class);

                //for my profile
                iv.putExtra("name", currentUser.getName());
                iv.putExtra("createdNumOfEvents", currentUser.getCreatedNumOfEvents());
                //pass events
                iv.putExtra("events", currentUser.getEvents());
                iv.putExtra("events_wait4approval", currentUser.getEvents_wait4approval());
                iv.putExtra("events_decline", currentUser.getEvents_decline());

                iv.putExtra("photoUrl", currentUser.getPhotoUrl());
                startActivity(iv);
                //
            }
        }
    });

    LinearLayout ll_aboutUs = (LinearLayout) findViewById(R.id.ll_about);
    ll_aboutUs.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // new changes
            Intent iv = new Intent(MainActivity.this, AboutUs.class);
            startActivity(iv);
            finish();
        }
    });

}