Example usage for android.widget RelativeLayout setBackgroundColor

List of usage examples for android.widget RelativeLayout setBackgroundColor

Introduction

In this page you can find the example usage for android.widget RelativeLayout setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:org.ounl.lifelonglearninghub.mediaplayer.cast.refplayer.browser.VideoBrowserListFragment.java

/**
 * Focus item for given position//from  www. j av  a2 s.co  m
 * 
 * @param l
 * @param position
 */
private void setFocus(ListView l, int position) {
    int iNumItem = l.getChildCount();
    for (int i = 0; i < iNumItem; i++) {
        RelativeLayout vRow = (RelativeLayout) l.getChildAt(i);
        vRow.setBackgroundColor(Color.WHITE);
    }

    l.getChildAt(position).setBackgroundColor(Color.parseColor(CastApplication.COLOR_ORANGE));
}

From source file:com.davidecirillo.multichoicesample.sampleToolbar.MySampleToolbarAdapter.java

/**
 * Override this method to implement a custom active/deactive state
 *///from w  w w  .ja  v a2 s .  com
@Override
public void setActive(View view, boolean state) {

    RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.get_started_relative_layout);

    if (relativeLayout != null) {
        if (state) {
            relativeLayout.setBackgroundColor(ContextCompat.getColor(mContext, R.color.colorPrimaryDark));
        } else {
            relativeLayout.setBackgroundColor(Color.WHITE);
        }
    }
}

From source file:com.softminds.matrixcalculator.base_activities.SplashScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    int SPLASH_TIME_OUT = 2000;

    ((GlobalValues) getApplication()).SetDonationKeyStatus();

    if (!((GlobalValues) getApplication()).DonationKeyFound()) { //if user is non pro then only check for offer key
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("promotion_offer", false);

        remoteConfig.setDefaults(hashMap);

        remoteConfig.setConfigSettings(//from www . ja  v a2  s . co  m
                new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG).build());

        final Task<Void> fetch = remoteConfig.fetch(TimeUnit.HOURS.toSeconds(6));
        //if offer exist then activate pro features
        fetch.addOnSuccessListener(new OnSuccessListener<Void>() {
            @Override
            public void onSuccess(Void aVoid) {
                remoteConfig.activateFetched();
                UpdateKey();
            }
        });
    }

    //init the key status here
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    boolean isDark = preferences.getBoolean("DARK_THEME_KEY", false);
    if (isDark)
        setTheme(R.style.AppThemeDark);
    else
        setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash_screen);
    TextView textView = findViewById(R.id.textView9);
    String s = "Version " + BuildConfig.VERSION_NAME;
    textView.setText(s);
    RelativeLayout Root = findViewById(R.id.splash_screen);
    try {
        if (isDark) {
            Root.setBackgroundColor(ContextCompat.getColor(this, R.color.DarkcolorPrimaryDark));
        } else
            Root.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
    } catch (NullPointerException e) {
        Toast.makeText(getApplicationContext(), R.string.FatalError, Toast.LENGTH_SHORT).show();
        e.printStackTrace();
        finish();
    }
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(intent);
            finish();

        }
    }, SPLASH_TIME_OUT);

    if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("PERSIST_ENABLER",
            false)) {
        try {
            FileInputStream fis = getApplicationContext().openFileInput("persist_data.mat");
            ObjectInputStream os = new ObjectInputStream(fis);
            ArrayList<MatrixV2> vars = (ArrayList<MatrixV2>) os.readObject();
            Log.d("TTT", "ABOUT TO RESTORE " + String.valueOf(vars.size()));
            os.close();
            fis.close();
            Log.d("TTT", "Previously on MainList "
                    + String.valueOf(((GlobalValues) getApplication()).GetCompleteList().size()));
            ((GlobalValues) getApplication()).GetCompleteList().clear();
            ((GlobalValues) getApplication()).GetCompleteList().addAll(vars);
            Log.d("TTT", "Total Value "
                    + String.valueOf(((GlobalValues) getApplication()).GetCompleteList().size()));
            Toast.makeText(getApplicationContext(), "Restored all Variables", Toast.LENGTH_SHORT).show();
        } catch (FileNotFoundException | ClassNotFoundException e) {
            // Nothing to restore simply skip
            e.printStackTrace();
        } catch (IOException e) {
            Toast.makeText(getApplicationContext(), "Cannot Load Persisted Variable. I/O Error",
                    Toast.LENGTH_SHORT).show();
            e.printStackTrace();
        }
    }
}

From source file:drawnzer.anurag.kollosal.KollosalPlayer.java

private void changeColor(int newColor) {
    //MusicFragment.getSlideLayout().setBackgroundColor(newColor);
    //pagerSlideTab.setIndicatorColor(getResources().getColor(R.color.semi_white));
    RelativeLayout ml = (RelativeLayout) findViewById(R.id.main_ui);
    ml.setBackgroundColor(newColor);
    LinearLayout listLayout = (LinearLayout) findViewById(R.id.lists_layout);
    listLayout.setBackgroundColor(newColor);
    ColorDrawable color = new ColorDrawable(newColor);
    lsMenu.setDivider(color);/*from  w w w. j a  v a 2s .  c  om*/
    lsTheme.setDivider(color);
    Drawable colorDrawable = new ColorDrawable(newColor);
    actionBar.setBackgroundDrawable(colorDrawable);
    // http://stackoverflow.com/questions/11002691/actionbar-setbackgrounddrawable-nulling-background-from-thread-handler
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowTitleEnabled(true);
    currentColor = newColor;
}

From source file:info.tellmetime.DaydreamService.java

@Override
public void onAttachedToWindow() {
    super.onAttachedToWindow();

    setInteractive(true);/*from   w  ww  .  j  a  v  a2  s.  c om*/

    setFullscreen(true);

    setContentView(R.layout.daydream);

    LinearLayout mClock = (LinearLayout) findViewById(R.id.clock);

    SharedPreferences settings = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
    mHighlightColor = settings.getInt(TellmetimeActivity.HIGHLIGHT, Color.WHITE);
    mBacklightColor = settings.getInt(TellmetimeActivity.BACKLIGHT,
            getResources().getColor(R.color.backlight_light));
    mMinutesSize = settings.getInt(TellmetimeActivity.MINUTES_SIZE, 36);
    isNightMode = settings.getBoolean(TellmetimeActivity.NIGHTMODE, false);

    setScreenBright(!isNightMode);
    findViewById(R.id.overlay).setBackgroundColor(
            getResources().getColor(isNightMode ? R.color.night_mode_overlay : android.R.color.transparent));

    RelativeLayout mSurface = (RelativeLayout) findViewById(R.id.surface);
    mSurface.setBackgroundColor(
            settings.getInt(TellmetimeActivity.BACKGROUND, getResources().getColor(R.color.background)));
    switch (settings.getInt(TellmetimeActivity.BACKGROUND_MODE, TellmetimeActivity.MODE_BACKGROUND_SOLID)) {
    case TellmetimeActivity.MODE_BACKGROUND_WALLPAPER:
        ((ImageView) findViewById(R.id.background_image))
                .setImageDrawable(WallpaperManager.getInstance(this).getDrawable());
        break;

    case TellmetimeActivity.MODE_BACKGROUND_IMAGE:
        try {
            ((ImageView) findViewById(R.id.background_image)).setImageBitmap(BitmapFactory.decodeStream(
                    new FileInputStream(new File(getFilesDir(), TellmetimeActivity.IMAGE_FILE_NAME))));
        } catch (Exception ignored) {
            // Image is not set, set background color loaded from setting is visible.
        }

        break;
    }

    mShorterEdge = Math.min(getResources().getDisplayMetrics().widthPixels,
            getResources().getDisplayMetrics().heightPixels);
    mDensity = getResources().getDisplayMetrics().density;

    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    lp.width = mShorterEdge;
    mClock.setLayoutParams(lp);

    Typeface mTypeface = Typeface.createFromAsset(getAssets(), "Roboto-BoldCondensed.ttf");
    final float mItemSize = mShorterEdge / mClock.getChildCount();
    final int mRowMargin = (int) -(mItemSize / 2.2);

    for (int i = 0; i < mClock.getChildCount(); i++) {
        LinearLayout row = (LinearLayout) mClock.getChildAt(i);

        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams();
        params.bottomMargin = mRowMargin;
        row.setLayoutParams(params);

        for (int j = 0; j < row.getChildCount(); j++) {
            TextView tv = (TextView) row.getChildAt(j);

            tv.setTypeface(mTypeface);
            tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mItemSize);
            tv.setTextColor(mBacklightColor);
            tv.setShadowLayer(mShorterEdge / 200 * mDensity, 0, 0, mBacklightColor);
        }
    }
    LinearLayout lastRow = (LinearLayout) mClock.getChildAt(mClock.getChildCount() - 1);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) lastRow.getLayoutParams();
    params.bottomMargin = 0;
    lastRow.setLayoutParams(params);

    TextView twenty = (TextView) findViewById(R.id.twenty);
    params = (LinearLayout.LayoutParams) twenty.getLayoutParams();
    params.leftMargin = 0;
    twenty.setLayoutParams(params);

    inflateMinutesIndicators();
}

From source file:ru.jango.j0widget.camera.fragment.AbstractCameraFragment.java

private RelativeLayout createRelativeLayout() {
    final RelativeLayout layout = new RelativeLayout(getActivity());
    layout.setLayoutParams(/*from   w  w w  .  j  a va 2  s . c o  m*/
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    layout.setBackgroundColor(Color.BLACK);

    return layout;
}

From source file:itcr.gitsnes.MainActivity.java

public void add_games(MenuItem item) {
    AddGame new_fragment = new AddGame();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.placeholder, new_fragment);
    transaction.addToBackStack(null);/*from w w w.j av a2  s  .co  m*/
    transaction.commit();

    RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback);
    rl.setBackgroundColor(Color.parseColor("#0099cc"));
    authButton.setVisibility(View.INVISIBLE);

}

From source file:itcr.gitsnes.MainActivity.java

public void advanced_query(MenuItem item) {

    SearchFrame new_fragment = new SearchFrame();
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.placeholder, new_fragment);
    transaction.addToBackStack(null);/*from w w w.j  a va  2s.  co  m*/
    transaction.commit();

    RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback);
    rl.setBackgroundColor(Color.parseColor("#ff8800"));
    authButton.setVisibility(View.INVISIBLE);

}

From source file:itcr.gitsnes.MainActivity.java

/** Inflates mainFrame/ListView with the next params from advanced_search layout:
 *      - name: if name isn't null/*from   w w  w.j ava 2 s. c o m*/
 *      - category: if category is different to empty
 */
public void searching(View view) {
    EditText name = (EditText) this.findViewById(R.id.src_name);
    EditText category = (EditText) this.findViewById(R.id.src_category);

    MasterGames new_fragment = new MasterGames(json_arr);
    new_fragment.setQname(name.getText().toString());
    new_fragment.setQcat(category.getText().toString());

    RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback);
    rl.setBackgroundColor(Color.parseColor("#009f28"));
    authButton.setVisibility(View.INVISIBLE);

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.placeholder, new_fragment);
    transaction.addToBackStack(null);
    transaction.commit();

}

From source file:itcr.gitsnes.MainActivity.java

public void goList(MenuItem item) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);/*from  w  w  w .jav  a  2  s  .  c  om*/
    String input = new BackendHandler().readJSON();
    try {
        json_arr = new JSONArray(input);
    } catch (JSONException e) {
        Log.i(TAG, e.toString());
    }

    RelativeLayout rl = (RelativeLayout) this.findViewById(R.id.mainback);
    rl.setBackgroundColor(Color.parseColor("#009f28"));
    authButton.setVisibility(View.INVISIBLE);
    MasterGames new_fragment = new MasterGames(json_arr);
    new_fragment.setQtype("all");

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.placeholder, new_fragment);
    transaction.addToBackStack(null);
    transaction.commit();

}