Example usage for android.widget RelativeLayout setBackgroundResource

List of usage examples for android.widget RelativeLayout setBackgroundResource

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:org.mozilla.gecko.AboutHomeContent.java

private void updateSyncLayout(boolean isFirstRun, boolean hasTopSites) {
    RelativeLayout syncContainer = (RelativeLayout) findViewById(R.id.sync_box_container);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) syncContainer.getLayoutParams();

    int below = R.id.all_top_sites_text;
    if (isFirstRun && !hasTopSites)
        below = R.id.top_sites_top;//  w w  w . ja  v a  2  s  . c o m
    else if (!hasTopSites)
        below = R.id.no_top_sites_text;

    int background = R.drawable.abouthome_bg_repeat;
    if (isFirstRun && !hasTopSites)
        background = 0;

    params.addRule(RelativeLayout.BELOW, below);
    syncContainer.setLayoutParams(params);

    syncContainer.setBackgroundResource(background);
}

From source file:com.mobicage.rogerthat.GroupDetailActivity.java

private void updateGroupForEdit() {
    T.UI();//from  w w  w. ja v  a2s  .co m
    final Button saveBtn = (Button) findViewById(R.id.save_group);
    final ImageView editBtn = (ImageView) findViewById(R.id.edit_group);
    final RelativeLayout updateGroupName = ((RelativeLayout) findViewById(R.id.update_group_name));
    final LinearLayout updateGroupAvatar = ((LinearLayout) findViewById(R.id.update_group_avatar));
    final ImageView newGroupAvatar = ((ImageView) findViewById(R.id.update_group_avatar_img));
    final Button updateAvatarBtn = (Button) findViewById(R.id.update_avatar);
    final Button cancelBtn = (Button) findViewById(R.id.cancel);

    final ImageView friendAvatar = (ImageView) findViewById(R.id.friend_avatar);
    final TextView friendName = (TextView) findViewById(R.id.friend_name);

    if (mEditing) {
        updateGroupName.setVisibility(View.VISIBLE);
        updateGroupAvatar.setVisibility(View.VISIBLE);
        updateGroupName.setBackgroundResource(android.R.drawable.edit_text);
        cancelBtn.setVisibility(View.VISIBLE);
        saveBtn.setVisibility(View.VISIBLE);
        editBtn.setVisibility(View.GONE);

        friendAvatar.setVisibility(View.GONE);
        friendName.setVisibility(View.GONE);

        updateGroupName.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mUpdateGroupName.requestFocus()) {
                    int pos = mUpdateGroupName.getText().length();
                    mUpdateGroupName.setSelection(pos);
                    UIUtils.showKeyboard(getApplicationContext());
                }
            }
        });

        OnClickListener newAvatarListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getNewAvatar(true);
                UIUtils.hideKeyboard(getApplicationContext(), mUpdateGroupName);
            }
        };

        updateAvatarBtn.setOnClickListener(newAvatarListener);
        newGroupAvatar.setOnClickListener(newAvatarListener);

    } else {
        updateGroupName.setVisibility(View.GONE);
        updateGroupAvatar.setVisibility(View.GONE);
        updateGroupName.setBackgroundResource(0);
        cancelBtn.setVisibility(View.GONE);
        saveBtn.setVisibility(View.GONE);
        editBtn.setVisibility(View.VISIBLE);

        friendAvatar.setVisibility(View.VISIBLE);
        friendName.setVisibility(View.VISIBLE);

        final byte[] byteArray;
        if (mPhotoSelected) {
            Bitmap bm = BitmapFactory.decodeFile(mUriSavedImage.getPath(), null);
            bm = ImageHelper.rotateBitmap(bm, mPhoneExifRotation);

            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bm.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byteArray = stream.toByteArray();
            File image;
            try {
                image = getTmpUploadPhotoLocation();
            } catch (IOException e) {
                L.d(e.getMessage());
                UIUtils.showLongToast(getApplicationContext(), e.getMessage());
                return;
            }
            image.delete();
            mPhotoSelected = false;
            mGroup.avatar = byteArray;
        }
        mGroup.name = mUpdateGroupName.getText().toString();
        mFriendsPlugin.getStore().updateGroup(mGroup.guid, mGroup.name, mGroup.avatar, null);
        mFriendsPlugin.putGroup(mGroup);

        mBackupMembers = new ArrayList<String>(mGroup.members);

        Intent intent = new Intent(mIsNewGroup ? FriendsPlugin.GROUP_ADDED : FriendsPlugin.GROUP_MODIFIED);
        intent.putExtra("guid", mGroup.guid);
        mService.sendBroadcast(intent);
    }
}

From source file:cm.aptoide.pt.MainActivity.java

public void setBackgroundLayoutStoreTheme(String theme, RelativeLayout bannerLayout) {
    EnumStoreTheme aptoideBackgroundTheme = null;
    String storeThemeString = "APTOIDE_STORE_THEME_" + theme.toUpperCase(Locale.ENGLISH);
    try {//from   w w w  .  j  av  a  2 s .  co  m
        aptoideBackgroundTheme = EnumStoreTheme.valueOf(storeThemeString);
    } catch (Exception e) {
        aptoideBackgroundTheme = EnumStoreTheme.APTOIDE_STORE_THEME_DEFAULT;
    }

    switch (aptoideBackgroundTheme) {
    case APTOIDE_STORE_THEME_DEFAULT:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_aptoide);
        break;
    case APTOIDE_STORE_THEME_BLUE:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_blue);
        break;
    case APTOIDE_STORE_THEME_DIMGRAY:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_dimgray);
        break;
    case APTOIDE_STORE_THEME_GOLD:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_gold);
        break;
    case APTOIDE_STORE_THEME_LIGHTSKY:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_lightsky);
        break;
    case APTOIDE_STORE_THEME_MAGENTA:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_magenta);
        break;
    case APTOIDE_STORE_THEME_MAROON:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_maroon);
        break;
    case APTOIDE_STORE_THEME_MIDNIGHT:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_midnight);
        break;
    case APTOIDE_STORE_THEME_ORANGE:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_orange);
        break;
    case APTOIDE_STORE_THEME_PINK:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_pink);
        break;
    case APTOIDE_STORE_THEME_RED:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_red);
        break;
    case APTOIDE_STORE_THEME_SEAGREEN:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_seagreen);
        break;
    case APTOIDE_STORE_THEME_SILVER:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_silver);
        break;
    case APTOIDE_STORE_THEME_SLATEGRAY:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_slategray);
        break;
    case APTOIDE_STORE_THEME_SPRINGGREEN:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_springgreen);
        break;

    default:
        bannerLayout.setBackgroundResource(R.drawable.actionbar_bgd_aptoide);
        break;
    }
}