Java Code Examples for android.app.ActionBar#setBackgroundDrawable()

The following examples show how to use android.app.ActionBar#setBackgroundDrawable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SomeActivity.java    From something.apk with MIT License 6 votes vote down vote up
private void configureActionbar(){
    ActionBar bar = getActionBar();
    bar.setHomeButtonEnabled(true);
    bar.setDisplayShowHomeEnabled(false);

    tint = new SystemBarTintManager(this);
    TypedValue tintColor = new TypedValue();
    if(getTheme().resolveAttribute(R.attr.statusBarBackground, tintColor, true)){
        tint.setStatusBarTintEnabled(true);
        tint.setTintColor(tintColor.data);
        defaultActionbarColor = tintColor.data;
        currentActionbarColor = tintColor.data;
    }else{
        tint.setStatusBarTintEnabled(false);
    }

    TypedValue actionbarBackground = new TypedValue();
    if(getTheme().resolveAttribute(R.attr.actionbarBackgroundLayerList, actionbarBackground, false)){
        actionbarBackgroundList = (LayerDrawable) getResources().getDrawable(actionbarBackground.data);
        actionbarBackgroundList.mutate();
        actionbarColor = (ColorDrawable) actionbarBackgroundList.findDrawableByLayerId(R.id.actionbar_background_color);
        actionbarColor.mutate();
        bar.setBackgroundDrawable(actionbarBackgroundList);
    }

}
 
Example 2
Source File: PXActionBarStyleAdapter.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean updateStyle(List<PXRuleSet> ruleSets, List<PXStylerContext> contexts) {
    // For the default case where we style just the action-bar, with no
    // virtual child involved, we will generate and set a background
    // drawable that will act as the default background.
    if (!super.updateStyle(ruleSets, contexts)) {
        return false;
    }
    PXStylerContext context = contexts.get(0);
    ActionBar actionBar = (ActionBar) context.getStyleable();
    // We just overwrite the exiting background. No states merging here.
    RectF bounds = getBounds(actionBar);
    actionBar.setBackgroundDrawable(PXDrawableUtil.createDrawable(bounds,
            context.getCombinedPaints()));
    return true;
}
 
Example 3
Source File: ColorPickerFragment.java    From UTubeTV with The Unlicense 6 votes vote down vote up
@Override
public void onColorChanged(int color) {

  if (color != mLastColor) {
    mLastColor = color;
    DUtils.log("setting: #" + Integer.toHexString(color));

    boolean actionbar = true;

    if (actionbar) {
      ActionBar bar = getActivity().getActionBar();

      bar.setBackgroundDrawable(new ColorDrawable(color));
      bar.setTitle(bar.getTitle());
    } else {
      getActivity().getWindow().setBackgroundDrawable(new ColorDrawable(color));

    }
  }
}
 
Example 4
Source File: UDActionBar.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
private void setupActionBarDrawable(Drawable drawable) {
    if (drawable != null) {
         ActionBar actionBar = LuaViewUtil.getActionBar(getGlobals());
        if (actionBar != null) {
            actionBar.setBackgroundDrawable(drawable);
        }
    }
}
 
Example 5
Source File: CommonUtils.java    From HHComicViewer with Apache License 2.0 5 votes vote down vote up
public static void initActionBar(ActionBar actionBar, int newColor) {
        Drawable colorDrawable = new ColorDrawable(newColor);
        LayerDrawable ld = new LayerDrawable(new Drawable[]{colorDrawable});
        if (actionBar != null) {
//            System.out.println("action bar != null");
            actionBar.setBackgroundDrawable(ld);
        }
    }
 
Example 6
Source File: CreateNewPostActivity.java    From platform-friends-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_new_post);

    final ImageView userPicture = (ImageView) findViewById(R.id.cna_userPicture);
    final TextView userName = (TextView) findViewById(R.id.cna_userDisplayName);

    final MyUser[] loggedUser = {BaseViewModel.getInstance().getLoggedUser()};
    if (loggedUser[0] == null) {
        BaseViewModel.EverliveAPP.workWith().
                users(MyUser.class).
                getMe().
                executeAsync(new RequestResultCallbackAction<MyUser>() {
                    @Override
                    public void invoke(RequestResult<MyUser> requestResult) {
                        if (requestResult.getSuccess()) {
                            loggedUser[0] = requestResult.getValue();
                            BaseViewModel.getInstance().setLoggedUser(loggedUser[0]);
                            loadUserInfo(userPicture, loggedUser[0], userName);
                        }
                    }
                });
    } else {
        loadUserInfo(userPicture, loggedUser[0], userName);
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.argb(255, 52, 73, 94)));
}
 
Example 7
Source File: GridActivity.java    From CardUI with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // Intialize and set the Action Bar to Holo Blue
        ActionBar actionBar = getActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5" )));
        
        GridView grid = (GridView) findViewById(R.id.myGrid);
         rowItems = new ArrayList<RowItem>();
         
        String[] titles = {"Movie1","Movie2","Movie3","Movie4","Movie5","Movie6","Movie7","Movie8"};
        String[] descriptions = {"First Movie","Second movie","Third Movie","Fourth Movie","Fifth Movie",
                        "Sixth Movie","Seventh Movie","Eighth Movie"};
        //Populate the List
        for (int i = 0; i < titles.length; i++) {
            RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
            rowItems.add(item);
        }

        // Set the adapter on the ListView
        LazyAdapter adapter = new LazyAdapter(getApplicationContext(), R.layout.grid_row, rowItems);
        grid.setAdapter(adapter);
        
        grid.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                        int arg2, long arg3) {
                                // TODO Auto-generated method stub
                                
                        }

                        
                });
}
 
Example 8
Source File: InterstitialActivity.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.show();
    actionBar.setTitle(null);
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    interstitialFragment = new InterstitialFragment();
    addFragment(interstitialFragment, InterstitialFragment.TAG);
}
 
Example 9
Source File: PresentationActivity.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = getActionBar();
    actionBar.show();
    actionBar.setTitle(null);
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
 
Example 10
Source File: GridActivity.java    From CardUI with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        // Intialize and set the Action Bar to Holo Blue
        ActionBar actionBar = getActionBar();
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5" )));
        
        GridView grid = (GridView) findViewById(R.id.myGrid);
         rowItems = new ArrayList<RowItem>();
         
        String[] titles = {"Movie1","Movie2","Movie3","Movie4","Movie5","Movie6","Movie7","Movie8"};
        String[] descriptions = {"First Movie","Second movie","Third Movie","Fourth Movie","Fifth Movie",
                        "Sixth Movie","Seventh Movie","Eighth Movie"};
        //Populate the List
        for (int i = 0; i < titles.length; i++) {
            RowItem item = new RowItem(images[i], titles[i], descriptions[i]);
            rowItems.add(item);
        }

        // Set the adapter on the ListView
        LazyAdapter adapter = new LazyAdapter(getApplicationContext(), R.layout.grid_row, rowItems);
        grid.setAdapter(adapter);
        
        grid.setOnItemSelectedListener(new OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                        int arg2, long arg3) {
                                // TODO Auto-generated method stub
                                
                        }

                        
                });
}
 
Example 11
Source File: ProductDetailActivity.java    From pos with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void initiateActionBar() {
	if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setTitle(res.getString(R.string.product_detail));
		actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33B5E5")));
	}
}
 
Example 12
Source File: SaleDetailActivity.java    From pos with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initiate actionbar.
 */
@SuppressLint("NewApi")
private void initiateActionBar() {
	if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setTitle(getResources().getString(R.string.sale));
		actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33B5E5")));
	}
}
 
Example 13
Source File: ProductDetailActivity.java    From pos with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void initiateActionBar() {
	if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setTitle(res.getString(R.string.product_detail));
		actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33B5E5")));
	}
}
 
Example 14
Source File: SaleDetailActivity.java    From pos with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initiate actionbar.
 */
@SuppressLint("NewApi")
private void initiateActionBar() {
	if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
		ActionBar actionBar = getActionBar();
		actionBar.setDisplayHomeAsUpEnabled(true);
		actionBar.setTitle(getResources().getString(R.string.sale));
		actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33B5E5")));
	}
}
 
Example 15
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);

	ActionBar actionBar = getActionBar();
	Bitmap b = BitmapFactory.decodeResource(getResources(),
			R.drawable.ic_launcher);

	actionBar.
		setBackgroundDrawable(new BitmapDrawable(getResources(), b));

	// add the custom view to the action bar

	actionBar.setCustomView(R.layout.actionbar_view);

	EditText search = (EditText) actionBar.getCustomView().findViewById(
			R.id.searchfield);
	search.setOnEditorActionListener(new OnEditorActionListener() {
		@Override
		public boolean onEditorAction(TextView v, int actionId,
				KeyEvent event) {
			Toast.makeText(MainActivity.this, "Search triggered",
					Toast.LENGTH_LONG).show();
			return false;
		}
	});
	actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
			| ActionBar.DISPLAY_SHOW_HOME);
}
 
Example 16
Source File: PlayerActivity.java    From FlutterYoutube with Apache License 2.0 4 votes vote down vote up
private void setupActionBarColor(ActionBar actionBar) {
    appBarColor = getIntent().getIntExtra("appBarColor" , 0xFF424242);
    actionBar.setBackgroundDrawable(new ColorDrawable(appBarColor));
    actionBar.setDisplayHomeAsUpEnabled(true);
}