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


Java LinearLayout.setBackgroundResource方法代码示例

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


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

示例1: custom

import android.widget.LinearLayout; //导入方法依赖的package包/类
public static Toast custom(@NonNull Context context, CharSequence text, @Nullable Drawable icon,
                           @ColorInt int backgroundColor, int duration, @DrawableRes int resid,
                           @Nullable Typeface tp, float cornerRadius,
                           @ColorInt int textColor, float textSize) {
    Toast toast = new Toast(context);

    View layout = ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.toast_layout, null);
    LinearLayout ll = (LinearLayout) layout.findViewById(R.id.base_layout);
    ll.setBackgroundResource(resid);
    GradientDrawable gd = (GradientDrawable) ll.getBackground().getCurrent();
    gd.setColor(backgroundColor);
    gd.setCornerRadius(cornerRadius);
    TextView tv_message = (TextView) layout.findViewById(R.id.toast_text);
    tv_message.setTextSize(textSize);
    tv_message.setTypeface(tp == null ? DEFAULT_TYPEFACE : tp);
    tv_message.setTextColor(textColor);
    ImageView iv_toast_image = (ImageView) layout.findViewById(R.id.toast_image);
    if (icon != null) {
        iv_toast_image.setImageDrawable(icon);
    }
    tv_message.setText(text);
    toast.setView(layout);
    toast.setDuration(duration);
    return toast;
}
 
开发者ID:chugh22,项目名称:ButterToast,代码行数:27,代码来源:ButterToast.java

示例2: write

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void write(FormulaListView formulaListView, Bitmap.CompressFormat format) throws Exception
{
    final LinearLayout f = formulaListView.getList();
    Bitmap bitmap = null;
    try
    {
        bitmap = Bitmap.createBitmap(f.getMeasuredWidth(), f.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
        final Canvas canvas = new Canvas(bitmap);
        f.setBackgroundColor(CompatUtils.getThemeColorAttr(f.getContext(), android.R.attr.windowBackground));
        f.draw(canvas);
    }
    catch (OutOfMemoryError e)
    {
        throw new Exception(e.getLocalizedMessage());
    }
    finally
    {
        f.setBackgroundResource(android.R.color.transparent);
    }
    bitmap.compress(format, 100, stream);
    stream.flush();
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:23,代码来源:ExportToImage.java

示例3: DummyArrow

import android.widget.LinearLayout; //导入方法依赖的package包/类
public DummyArrow(Context context){
    this.context = context;

    bottom_arrow = new LinearLayout(context);
    scale = context.getResources().getDisplayMetrics().density;
    dpAsPixels = (int) (20 * scale + 0.5f);
    LinearLayout.LayoutParams arrow_params = new LinearLayout.LayoutParams(dpAsPixels, dpAsPixels, 1f);
    arrow_params.gravity = Gravity.CENTER_HORIZONTAL;
    bottom_arrow.setLayoutParams(arrow_params);
    bottom_arrow.setOrientation(LinearLayout.HORIZONTAL);

    bottom_arrow.setBackgroundResource(R.drawable.upper_traingle);

    value = bottom_arrow.getLayoutParams().height;

}
 
开发者ID:salRoid,项目名称:InstaBadge,代码行数:17,代码来源:DummyArrow.java

示例4: addItemView

import android.widget.LinearLayout; //导入方法依赖的package包/类
private View addItemView(int rid, String text) {
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setId(rid);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, DensityUtil.dip2px(context, 44f)));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setBackgroundResource(R.drawable.base_item_bg_selector);
    linearLayout.setOnClickListener(this);
    TextView textView = new TextView(context);
    textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1));
    textView.setText(text);
    textView.setTextColor(context.getResources().getColor(R.color.bottom_dialog_textcolor));
    textView.setTextSize(16f);
    textView.setGravity(Gravity.CENTER);
    linearLayout.removeAllViews();
    linearLayout.addView(textView);
    return  linearLayout;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:18,代码来源:CustomBottomDialog.java

示例5: getPageBody

import android.widget.LinearLayout; //导入方法依赖的package包/类
private LinearLayout getPageBody() {
	llBody = new LinearLayout(getContext());
	llBody.setId(2);
	int resId = getBitmapRes(activity, "edittext_back");
	if (resId > 0) {
		llBody.setBackgroundResource(resId);
	}
	llBody.setOrientation(LinearLayout.VERTICAL);
	RelativeLayout.LayoutParams lpBody = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpBody.addRule(RelativeLayout.ALIGN_LEFT, llTitle.getId());
	lpBody.addRule(RelativeLayout.BELOW, llTitle.getId());
	lpBody.addRule(RelativeLayout.ALIGN_RIGHT, llTitle.getId());
	if (!dialogMode) {
		lpBody.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	}
	int dp_3 = dipToPx(getContext(), 3);
	lpBody.setMargins(dp_3, dp_3, dp_3, dp_3);
	llBody.setLayoutParams(lpBody);

	llBody.addView(getMainBody());
	llBody.addView(getSep());
	llBody.addView(getPlatformList());

	return llBody;
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:27,代码来源:EditPage.java

示例6: createAnimLayout

import android.widget.LinearLayout; //导入方法依赖的package包/类
private static ViewGroup createAnimLayout()
{
    ViewGroup rootView = (ViewGroup) mActivity.getWindow().getDecorView();
    LinearLayout animLayout = new LinearLayout(mActivity);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT ,
            LinearLayout.LayoutParams.MATCH_PARENT);
    animLayout.setLayoutParams(lp);
    animLayout.setBackgroundResource(android.R.color.transparent);
    rootView.addView(animLayout);
    return animLayout;
}
 
开发者ID:z13538657403,项目名称:CustomShoppingCarDemo,代码行数:12,代码来源:GoodsAnimUtil.java

示例7: createToastView

import android.widget.LinearLayout; //导入方法依赖的package包/类
private static View createToastView(Context context) {
        RelativeLayout root = new RelativeLayout(context);
        root.setTag("root");
        if (isSupport()) {
            root.setBackgroundResource(context.getResources().getIdentifier("colorAccent", "color", context.getPackageName()));
        }
        //root.setBackgroundColor(Color.RED);
        WindowManager.LayoutParams rootParams = new WindowManager.LayoutParams(-1, -2);
        rootParams.gravity = Gravity.TOP;
        root.setLayoutParams(rootParams);

        LinearLayout layout = new LinearLayout(context);
        layout.setOrientation(LinearLayout.HORIZONTAL);
        if (isSupport()) {
            layout.setBackgroundResource(context.getResources().getIdentifier("colorAccent", "color", context.getPackageName()));
        }
//        layout.setBackgroundResource(android.R.color.holo_red_dark);
//        layout.setVerticalGravity(Gravity.VERTICAL_GRAVITY_MASK);
        final RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(-2, -2);
        params.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(params);
        layout.setMinimumHeight(getMinHeight(context));

        ImageView imageView = new ImageView(context);
        imageView.setTag("image");
        imageView.setVisibility(View.GONE);

        TextView textView = new TextView(context);
        textView.setTag("text");
        textView.setTextColor(Color.WHITE);

        final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
        layoutParams.setMargins(getMinHeight(context, 10), 0, 0, 0);
        layoutParams.gravity = Gravity.CENTER_VERTICAL;

        layout.addView(imageView, layoutParams);
        layout.addView(textView, layoutParams);
        root.addView(layout);
        return root;
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:41,代码来源:T.java

示例8: initViews

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public void initViews() {
    builder = builder();
    if (builder == null) {
        throw new IllegalArgumentException("builder 不能为空");
    }
    magicIndicator = (MagicIndicator) findViewById(R.id.base_title_magic_indicator);
    mViewPager = (NoScrollViewPager) findViewById(R.id.base_title_view_pager);
    magicIndicatorParent = (LinearLayout) findViewById(R.id.base_title_magic_parent);
    cutOffRule = findViewById(R.id.base_title_cut_off_rule);

    magicIndicatorParent.setBackgroundResource(builder.getMultiTypeBgColor());

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            UIUtil.dip2px(mContext, builder.getTitleViewHeight()));
    layoutParams.setMargins(UIUtil.dip2px(mContext, builder.getHeadViewMarginsLeft()),
            UIUtil.dip2px(mContext, builder.getHeadViewMarginsTop()),
            UIUtil.dip2px(mContext, builder.getHeadViewMarginsRight()),
            UIUtil.dip2px(mContext, builder.getHeadViewMarginsBottom()));
    magicIndicator.setLayoutParams(layoutParams);
    magicIndicator.requestLayout();

    if (!builder.isShowCutOffRule()) {
        cutOffRule.setVisibility(View.GONE);
    }
    if (builder.getMultiTypeBodyBgColor() != 0) {
        mViewPager.setBackgroundResource(builder.getMultiTypeBodyBgColor());
    }
    mViewPager.setScroll(builder.isScroll());
    cutOffRule.setBackgroundResource(builder.getCutOffRuleColor());

}
 
开发者ID:zengcanxiang,项目名称:MVP-Practice-Project-Template,代码行数:33,代码来源:MultiTypeActivity.java

示例9: makeText

import android.widget.LinearLayout; //导入方法依赖的package包/类
public static Toast makeText(Context context,String message,int duration,int type,boolean androidicon){
    Toast toast = new Toast(context);
    toast.setDuration(duration);
    View layout = LayoutInflater.from(context).inflate(R.layout.fancytoast_layout, null, false);
    TextView l1 = (TextView) layout.findViewById(R.id.toast_text);
    LinearLayout linearLayout=(LinearLayout) layout.findViewById(R.id.toast_type);
    ImageView img=(ImageView) layout.findViewById(R.id.toast_icon);
    ImageView img1=(ImageView) layout.findViewById(R.id.imageView4);
    l1.setText(message);
    if(androidicon==true)
    img1.setVisibility(View.VISIBLE);
    else if(androidicon==false)
    img1.setVisibility(View.GONE);
    if(type==1)
    { linearLayout.setBackgroundResource(R.drawable.success_shape);
      img.setImageResource(R.drawable.ic_check_black_24dp);
    }
    else if (type==2)
    { linearLayout.setBackgroundResource(R.drawable.warning_shape);
      img.setImageResource(R.drawable.ic_pan_tool_black_24dp);
    }
    else if (type==3)
    { linearLayout.setBackgroundResource(R.drawable.error_shape);
      img.setImageResource(R.drawable.ic_clear_black_24dp);
    }
    else if (type==4)
    { linearLayout.setBackgroundResource(R.drawable.info_shape);
      img.setImageResource(R.drawable.ic_info_outline_black_24dp);
    }
    else if (type==5)
    { linearLayout.setBackgroundResource(R.drawable.default_shape);
      img.setVisibility(View.GONE);
    }
    else if (type==6)
    { linearLayout.setBackgroundResource(R.drawable.confusing_shape);
      img.setImageResource(R.drawable.ic_refresh_black_24dp);
    }
    toast.setView(layout);
    return toast;
}
 
开发者ID:Shashank02051997,项目名称:FancyToast-Android,代码行数:41,代码来源:FancyToast.java

示例10: setupBottomArrow

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void setupBottomArrow() {

        bottom_arrow = new LinearLayout(context);
        dpAsPixels = (int) (20 * scale + 0.5f);
        LayoutParams arrow_params = new LinearLayout.LayoutParams(dpAsPixels, dpAsPixels);
        arrow_params.gravity = Gravity.CENTER_HORIZONTAL;
        bottom_arrow.setLayoutParams(arrow_params);
        bottom_arrow.setOrientation(LinearLayout.HORIZONTAL);

        bottom_arrow.setBackgroundResource(R.drawable.triangle);
        addView(outer_container);
        addView(bottom_arrow);

    }
 
开发者ID:salRoid,项目名称:InstaBadge,代码行数:15,代码来源:InstaBadgeView.java

示例11: getWeekTitleView

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 第一行日期
 * @param weekDayName
 * @param dayName
 * @param firstRowHeight
 * @param isToday
 * @return
 */
public View getWeekTitleView(String weekDayName,String dayName,int firstRowHeight,boolean isToday) {
    LinearLayout headViewCell = new LinearLayout(mContext);
    headViewCell.setBackgroundResource(R.drawable.head_view_back);
    headViewCell.setOrientation(LinearLayout.VERTICAL);

    LinearLayout.LayoutParams tvLLP = new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
            firstRowHeight / 2);

    TextView dayTV = new TextView(mContext);
    dayTV.setText(weekDayName);
    dayTV.setLayoutParams(tvLLP);
    dayTV.setGravity(Gravity.CENTER);
    dayTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, 11);
    headViewCell.addView(dayTV);

    TextView dateTV = new TextView(mContext);
    dateTV.setLayoutParams(tvLLP);
    dateTV.setText(dayName);
    dateTV.setGravity(Gravity.CENTER | Gravity.BOTTOM);
    dateTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    headViewCell.addView(dateTV);

    if (isToday) {
        headViewCell.setBackgroundColor(0x77069ee9);
        dateTV.setTextColor(Color.WHITE);
        dayTV.setTextColor(Color.WHITE);
    }
    return headViewCell;
}
 
开发者ID:huangshuai-IOT,项目名称:SScheduleView-Android,代码行数:38,代码来源:CustomSSViewAdapter.java

示例12: initViews

import android.widget.LinearLayout; //导入方法依赖的package包/类
protected void initViews(View view) {
		mLayoutTimeStampContainer = (RelativeLayout) view
				.findViewById(R.id.message_layout_timecontainer);
		mHtvTimeStampTime = (HandyTextView) view
				.findViewById(R.id.message_timestamp_htv_time);
		mHtvTimeStampDistance = (HandyTextView) view
				.findViewById(R.id.message_timestamp_htv_distance);

		mLayoutLeftContainer = (RelativeLayout) view
				.findViewById(R.id.message_layout_leftcontainer);
		mLayoutStatus = (LinearLayout) view
				.findViewById(R.id.message_layout_status);
		mHtvStatus = (HandyTextView) view.findViewById(R.id.message_htv_status);

		mLayoutMessageContainer = (LinearLayout) view
				.findViewById(R.id.message_layout_messagecontainer);
		mLayoutMessageContainer.setBackgroundResource(mBackground);

		mLayoutRightContainer = (LinearLayout) view
				.findViewById(R.id.message_layout_rightcontainer);
		mIvPhotoView = (ImageView) view.findViewById(R.id.message_iv_userphoto);
		onInitViews();
		
		mIvPhotoView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
//				mOnClickAvatarListener.onClick();
				
			}
		});
	}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:34,代码来源:MessageItem.java

示例13: PhotoVideoView

import android.widget.LinearLayout; //导入方法依赖的package包/类
public PhotoVideoView(Context context) {
    super(context);

    container = new FrameLayout(context);
    addView(container, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    imageView = new BackupImageView(context);
    imageView.getImageReceiver().setNeedsQualityThumb(true);
    imageView.getImageReceiver().setShouldGenerateQualityThumb(true);
    container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    videoInfoContainer = new LinearLayout(context);
    videoInfoContainer.setOrientation(LinearLayout.HORIZONTAL);
    videoInfoContainer.setBackgroundResource(R.drawable.phototime);
    videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
    videoInfoContainer.setGravity(Gravity.CENTER_VERTICAL);
    container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT));

    ImageView imageView1 = new ImageView(context);
    imageView1.setImageResource(R.drawable.ic_video);
    videoInfoContainer.addView(imageView1, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));

    videoTextView = new TextView(context);
    videoTextView.setTextColor(0xffffffff);
    videoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
    videoTextView.setGravity(Gravity.CENTER_VERTICAL);
    videoInfoContainer.addView(videoTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 4, 0, 0, 1));

    selector = new View(context);
    selector.setBackgroundResource(R.drawable.list_selector);
    addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setVisibility(INVISIBLE);
    addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 0, 2, 2, 0));
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:37,代码来源:SharedPhotoVideoCell.java

示例14: onCreateView

import android.widget.LinearLayout; //导入方法依赖的package包/类
protected View onCreateView(Context context) {
		mainLayout = new LinearLayout(context);
		mainLayout.setBackgroundResource(ResHelper.getColorRes(context, "bbs_title_bg"));
		mainLayout.setOrientation(LinearLayout.VERTICAL);
		mainLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

		titleBar = new TitleBar(context) {
			@Override
			protected View getCenterView() {
				View centerview = getTitleCenterView();
				if (centerview == null) {
					return super.getCenterView();
				}
				return centerview;
			}
		};
		LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
		mainLayout.addView(titleBar, llp);

		vLine = new View(context);
		vLine.setBackgroundResource(ResHelper.getColorRes(context, "bbs_mainviewtitle_bg"));
		mainLayout.addView(vLine, ViewGroup.LayoutParams.MATCH_PARENT, ResHelper.dipToPx(context, 1) / 2);
		vLine.setVisibility(View.GONE);

		View contentView = onCreateContentView(context);
//		contentView.setBackgroundResource(ResHelper.getColorRes(context, "bbs_bg"));
		llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
		llp.weight = 1;
		mainLayout.addView(contentView, llp);

		titleBar.setOnClickListener(newTitleBarClickListener());
		return mainLayout;
	}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:34,代码来源:BasePageWithTitle.java

示例15: onNavigationItemSelected

import android.widget.LinearLayout; //导入方法依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    bg = (LinearLayout)findViewById(R.id.bg);
    preferences = getSharedPreferences("MY_PREFERENCE", Context.MODE_PRIVATE);
    editor = preferences.edit();

    if (id == R.id.nav_all) {
        setSimpleAdapter();
    } else if (id == R.id.nav_work) {
        setSimpleAdapterByTag(R.mipmap.icon_work);
    } else if (id == R.id.nav_study) {
        setSimpleAdapterByTag(R.mipmap.icon_study);
    } else if (id == R.id.nav_anniversary) {
        setSimpleAdapterByTag(R.mipmap.icon_love);
    } else if (id == R.id.nav_birthday) {
        setSimpleAdapterByTag(R.mipmap.icon_birthday);
    } else if (id == R.id.nav_life) {
        setSimpleAdapterByTag(R.mipmap.icon_life);
    } else if (id == R.id.nav_event) {
        setSimpleAdapterByTag(R.mipmap.icon_event);
    } else if (id == R.id.nav_change) {
        //更改背景
        bgNum = (bgNum+ 1)% 5;

        switch (bgNum) {
            case 1:
                bg.setBackgroundResource(R.mipmap.bg1);
                editor.putInt("bgNum",R.mipmap.bg1);
                editor.commit();
                break;
            case 2:
                bg.setBackgroundResource(R.mipmap.bg2);
                editor.putInt("bgNum",R.mipmap.bg2);
                editor.commit();
                break;
            case 3:
                bg.setBackgroundResource(R.mipmap.bg4);
                editor.putInt("bgNum",R.mipmap.bg4);
                editor.commit();
                break;
            case 4:
                bg.setBackgroundResource(R.mipmap.bg5);
                editor.putInt("bgNum",R.mipmap.bg5);
                editor.commit();
                break;
            case 0:
                bg.setBackgroundResource(R.mipmap.bg7);
                editor.putInt("bgNum",R.mipmap.bg7);
                editor.commit();
                break;
            default:
                break;
        }
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:613-sysu,项目名称:Days,代码行数:63,代码来源:MainActivity.java


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