Java Code Examples for androidx.constraintlayout.widget.ConstraintLayout#setBackgroundColor()

The following examples show how to use androidx.constraintlayout.widget.ConstraintLayout#setBackgroundColor() . 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: OfflineActivity.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // Hide any toolbar an apps theme might automatically place in activities. Typically creating an
  // activity style would cover this issue but this seems to prevent us from getting the users
  // application colorPrimary color.
  getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
  getSupportActionBar().hide();
  setContentView(R.layout.mapbox_offline_activity);

  ConstraintLayout toolbar = findViewById(R.id.place_picker_toolbar);
  int color = ColorUtils.getMaterialColor(this, R.attr.colorPrimary);
  toolbar.setBackgroundColor(color);

  // Add autocomplete fragment if this is first creation
  if (savedInstanceState == null) {

    RegionSelectionFragment fragment;

    RegionSelectionOptions regionSelectionOptions
      = getIntent().getParcelableExtra(OfflinePluginConstants.REGION_SELECTION_OPTIONS);
    if (regionSelectionOptions != null) {
      fragment = RegionSelectionFragment.newInstance(regionSelectionOptions);
    } else {
      fragment = RegionSelectionFragment.newInstance();
    }

    getSupportFragmentManager().beginTransaction()
      .add(R.id.fragment_container, fragment, RegionSelectionFragment.TAG).commit();

    fragment.setSelectedCallback(this);
  }
}
 
Example 2
Source File: PlacePickerActivity.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void customizeViews() {
  ConstraintLayout toolbar = findViewById(R.id.place_picker_toolbar);
  if (options != null && options.toolbarColor() != null) {
    toolbar.setBackgroundColor(options.toolbarColor());
  } else {
    int color = ColorUtils.getMaterialColor(this, R.attr.colorPrimary);
    toolbar.setBackgroundColor(color);
  }
}