当前位置: 首页>>代码示例>>Java>>正文


Java RelativeLayout.setBackgroundDrawable方法代码示例

本文整理汇总了Java中android.widget.RelativeLayout.setBackgroundDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java RelativeLayout.setBackgroundDrawable方法的具体用法?Java RelativeLayout.setBackgroundDrawable怎么用?Java RelativeLayout.setBackgroundDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.RelativeLayout的用法示例。


在下文中一共展示了RelativeLayout.setBackgroundDrawable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dealMessageStatus

import android.widget.RelativeLayout; //导入方法依赖的package包/类
/**
 * 处理消息的发送状态以及是否显示时间tip
 *
 * @param message         当前消息
 * @param previousMessage 前一条消息
 * @param position        当前item位置
 * @param tvDate          时间组件
 * @param progressBar     进度条组件
 * @param failLayout      状态容器
 */
protected final void dealMessageStatus(IMMessage message, IMMessage previousMessage, int position,
                                       TextView tvDate, ProgressBar progressBar, RelativeLayout failLayout) {
    if (message.getStatus() == Status.SENDING) {
        progressBar.setVisibility(View.VISIBLE);
        failLayout.setBackgroundColor(Color.TRANSPARENT);
    } else if (message.getStatus() == Status.SUCCESS) {
        progressBar.setVisibility(View.GONE);
        failLayout.setBackgroundColor(Color.TRANSPARENT);
    } else if (message.getStatus() == Status.FAILED) {
        progressBar.setVisibility(View.GONE);
        failLayout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.kf5_message_send_failed_img_drawable));
        failLayout.setOnClickListener(new MessageResendListener(context, message));
    }
    dealDate(position, tvDate, message, previousMessage);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:26,代码来源:AbstractHolder.java

示例2: getPageView

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private RelativeLayout getPageView() {
	rlPage = new RelativeLayout(getContext());
	rlPage.setBackgroundDrawable(background);
	if (dialogMode) {
		RelativeLayout rlDialog = new RelativeLayout(getContext());
		rlDialog.setBackgroundColor(0xc0323232);
		int dp_8 = dipToPx(getContext(), 8);
		int width = getScreenWidth(getContext()) - dp_8 * 2;
		RelativeLayout.LayoutParams lpDialog = new RelativeLayout.LayoutParams(
				width, LayoutParams.WRAP_CONTENT);
		lpDialog.topMargin = dp_8;
		lpDialog.bottomMargin = dp_8;
		lpDialog.addRule(RelativeLayout.CENTER_IN_PARENT);
		rlDialog.setLayoutParams(lpDialog);
		rlPage.addView(rlDialog);

		rlDialog.addView(getPageTitle());
		rlDialog.addView(getPageBody());
		rlDialog.addView(getImagePin());
	} else {
		rlPage.addView(getPageTitle());
		rlPage.addView(getPageBody());
		rlPage.addView(getImagePin());
	}
	return rlPage;
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:27,代码来源:EditPage.java

示例3: setContent

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void setContent() {
    setContentView(R.layout.activity_login);
    screen = (RelativeLayout)findViewById(R.id.rl);
    ColorDrawable[] color = {new ColorDrawable(getResources().getColor(R.color.colorAccent)), new ColorDrawable(getResources().getColor(R.color.colorPrimary)) };
    TransitionDrawable trans = new TransitionDrawable(color);
    screen.setBackgroundDrawable(trans);
    trans.startTransition(1800);

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
    mGoogleApiClient = new GoogleApiClient.Builder(getBaseContext())
            .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    mAuth = FirebaseAuth.getInstance();

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    root= database.getReference("room_names");
    loadRooms();
    new CountDownTimer(2500, 1000) {
        public void onTick(long millisUntilDone) { }
        public void onFinish() {
            currentUser = mAuth.getCurrentUser();
            updateUI(currentUser);
        }
    }.start();
}
 
开发者ID:YoungPeacock,项目名称:FantaF1,代码行数:26,代码来源:LoginActivity.java

示例4: showBadgeAtIndex

import android.widget.RelativeLayout; //导入方法依赖的package包/类
/**
 * Show badge at index
 *
 * @param itemIndex index
 * @param badgeText badge count text
 */
public void showBadgeAtIndex(int itemIndex, int badgeText, @ColorInt int badgeColor) {
    if (itemIndex < 0 || itemIndex > spaceItems.size()) {
        throwArrayIndexOutOfBoundsException(itemIndex);
    } else {
        RelativeLayout badgeView = badgeList.get(itemIndex);

        /**
         * Set circle background to badge view
         */
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            badgeView.setBackground(BadgeHelper.makeShapeDrawable(badgeColor));
        } else {
            badgeView.setBackgroundDrawable(BadgeHelper.makeShapeDrawable(badgeColor));
        }

        BadgeItem badgeItem = new BadgeItem(itemIndex, badgeText, badgeColor);
        BadgeHelper.showBadge(badgeView, badgeItem, shouldShowBadgeWithNinePlus);
        badgeSaveInstanceHashMap.put(itemIndex, badgeItem);
    }
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:27,代码来源:SpaceNavigationView.java

示例5: getLayout

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private View getLayout() {
    int horizontalPadding = (int) getTypedValueInDP(context, DEFAULT_HORIZONTAL_PADDING);
    int verticalPadding = (int) getTypedValueInDP(context, DEFAULT_VERTICAL_PADDING);
    RelativeLayout rootLayout = new RelativeLayout(context);
    rootLayout.setPadding(horizontalPadding, verticalPadding, horizontalPadding, verticalPadding);
    rootLayout.setBackgroundDrawable(getShape());
    rootLayout.addView(getTextView());
    return rootLayout;
}
 
开发者ID:suragch,项目名称:mongol-library,代码行数:10,代码来源:MongolToast.java

示例6: initTitleBar

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private View initTitleBar() {
    RelativeLayout titleBar = new RelativeLayout(this);
    titleBar.setLayoutParams(new LayoutParams(-1, ResourceManager.dp2px(this, 45)));
    titleBar.setBackgroundDrawable(ResourceManager.getNinePatchDrawable(this, "weibosdk_navigationbar_background.9.png"));
    this.mLeftBtn = new TextView(this);
    this.mLeftBtn.setClickable(true);
    this.mLeftBtn.setTextSize(2, 17.0f);
    this.mLeftBtn.setTextColor(ResourceManager.createColorStateList(-32256, 1728020992));
    this.mLeftBtn.setText(ResourceManager.getString(this, CANCEL_EN, "关闭", "关闭"));
    RelativeLayout.LayoutParams leftBtnLp = new RelativeLayout.LayoutParams(-2, -2);
    leftBtnLp.addRule(5);
    leftBtnLp.addRule(15);
    leftBtnLp.leftMargin = ResourceManager.dp2px(this, 10);
    leftBtnLp.rightMargin = ResourceManager.dp2px(this, 10);
    this.mLeftBtn.setLayoutParams(leftBtnLp);
    titleBar.addView(this.mLeftBtn);
    this.mTitleText = new TextView(this);
    this.mTitleText.setTextSize(2, 18.0f);
    this.mTitleText.setTextColor(-11382190);
    this.mTitleText.setEllipsize(TruncateAt.END);
    this.mTitleText.setSingleLine(true);
    this.mTitleText.setGravity(17);
    this.mTitleText.setMaxWidth(ResourceManager.dp2px(this, 160));
    RelativeLayout.LayoutParams titleTextLy = new RelativeLayout.LayoutParams(-2, -2);
    titleTextLy.addRule(13);
    this.mTitleText.setLayoutParams(titleTextLy);
    titleBar.addView(this.mTitleText);
    return titleBar;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:30,代码来源:WeiboSdkBrowser.java

示例7: forceShowBadge

import android.widget.RelativeLayout; //导入方法依赖的package包/类
/**
 * Force show badge without animation
 *
 * @param view      target budge
 * @param badgeItem BadgeItem object
 */
static void forceShowBadge(RelativeLayout view, BadgeItem badgeItem, boolean shouldShowBadgeWithNinePlus) {
    Utils.changeViewVisibilityVisible(view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(makeShapeDrawable(badgeItem.getBadgeColor()));
    } else {
        view.setBackgroundDrawable(makeShapeDrawable(badgeItem.getBadgeColor()));
    }
    TextView badgeTextView = (TextView) view.findViewById(R.id.badge_text_view);
    if (shouldShowBadgeWithNinePlus)
        badgeTextView.setText(badgeItem.getBadgeText());
    else
        badgeTextView.setText(badgeItem.getFullBadgeText());
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:20,代码来源:BadgeHelper.java

示例8: getImageWrapper

import android.widget.RelativeLayout; //导入方法依赖的package包/类
public static RelativeLayout getImageWrapper(Context context, MenuObject menuItem, int menuItemSize,
                                             View.OnClickListener onCLick, View.OnLongClickListener onLongClick,
                                             boolean showDivider) {
    RelativeLayout imageWrapper = new RelativeLayout(context);
    LinearLayout.LayoutParams imageWrapperLayoutParams = new LinearLayout.LayoutParams(menuItemSize, menuItemSize);
    imageWrapper.setLayoutParams(imageWrapperLayoutParams);
    imageWrapper.setOnClickListener(onCLick);
    imageWrapper.setOnLongClickListener(onLongClick);
    imageWrapper.addView(Utils.getItemImageButton(context, menuItem));
    if (showDivider) {
        imageWrapper.addView(getDivider(context, menuItem));
    }

    if (menuItem.getBgColor() != 0) {
        imageWrapper.setBackgroundColor(menuItem.getBgColor());
    } else if (menuItem.getBgDrawable() != null) {
        if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            imageWrapper.setBackgroundDrawable(menuItem.getBgDrawable());
        } else {
            imageWrapper.setBackground(menuItem.getBgDrawable());
        }
    } else if (menuItem.getBgResource() != 0) {
        imageWrapper.setBackgroundResource(menuItem.getBgResource());
    } else {
        imageWrapper.setBackgroundColor(context.getResources().getColor(R.color.menu_item_background));
    }
    return imageWrapper;
}
 
开发者ID:zongkaili,项目名称:MenuSet,代码行数:29,代码来源:Utils.java

示例9: initView

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(CENTER_VERTICAL);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);
        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:72,代码来源:BGABanner.java

示例10: initView

import android.widget.RelativeLayout; //导入方法依赖的package包/类
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);


        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:74,代码来源:BGABanner.java


注:本文中的android.widget.RelativeLayout.setBackgroundDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。