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


Java LinearLayout.setBackground方法代码示例

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


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

示例1: disableDays

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * This view disables tapping on the day objects and on the endDate label. It also
 * colors them following the material design specification.
  */
private void disableDays() {
    double opacity = 0.26; //Following the material specification, disabled buttons have opacity 26%
    for (int i = 0; i < weekdaysSelection.length; i++) {
        LinearLayout day = getDayLayout(i);
        day.setOnClickListener(null);
        endDateTextView.setOnClickListener(null);
        endDateTextView.setAlpha( (float) (opacity * 255 /100));
        int colorBlack = ContextCompat.getColor(getBaseContext(), R.color.black);
        if (day.getBackground()== null) {
            Drawable bg = ContextCompat.getDrawable(getBaseContext(), R.drawable.circle_step);
            bg.setColorFilter(new PorterDuffColorFilter(colorBlack, PorterDuff.Mode.SRC_IN));
            bg.setAlpha((int) (opacity * 255));
            day.setBackground(bg);
        } else {
            day.getBackground().setColorFilter(new PorterDuffColorFilter(colorBlack, PorterDuff.Mode.SRC_IN));
            day.getBackground().setAlpha((int) (opacity * 255));
        }
    }
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:24,代码来源:AddPillSetTime.java

示例2: modifyUniformBlueStyle

import android.widget.LinearLayout; //导入方法依赖的package包/类
public static void modifyUniformBlueStyle(BasePageWithTitle basepage) {
	if (basepage == null) {
		return;
	}
	Context context = basepage.getContext();
	TitleBar titlebar = basepage.getTitleBar();
	LinearLayout mainlayout = basepage.getMainLayout();
	if (titlebar == null) {
		throw new IllegalArgumentException("titleBar is not initialized!");
	} else {
		titlebar.setBackgroundColor(Color.TRANSPARENT);
		titlebar.getTitleTextView().setTextColor(context.getResources().getColor(basepage.getColorId("bbs_white")));
		setTextSize(titlebar.getTitleTextView(), "bbs_theme0_title_txt_size");
	}

	if (mainlayout == null) {
		throw new IllegalArgumentException("mainLayout is not initialized!");
	} else {
		Drawable drawable = context.getResources().getDrawable(basepage.getDrawableId("bbs_theme0_bg_userpage"));
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
			mainlayout.setBackgroundDrawable(drawable);
		} else {
			mainlayout.setBackground(drawable);
		}
	}
	basepage.setStatusBarColor(context.getResources().getColor(basepage.getColorId("bbs_theme0_statusbar_blue")));
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:28,代码来源:Theme0StyleModifier.java

示例3: modifyUniformWhiteStyle

import android.widget.LinearLayout; //导入方法依赖的package包/类
public static void modifyUniformWhiteStyle(BasePageWithTitle basepage) {
	if (basepage == null) {
		return;
	}
	Context context = basepage.getContext();
	TitleBar titlebar = basepage.getTitleBar();
	LinearLayout mainlayout = basepage.getMainLayout();
	if (titlebar == null) {
		throw new IllegalArgumentException("titleBar is not initialized!");
	} else {
		titlebar.setBackgroundColor(Color.TRANSPARENT);
		if(titlebar.getTitleTextView() != null) {
			titlebar.getTitleTextView().setTextColor(context.getResources().getColor(basepage.getColorId("bbs_theme0_pagetext")));
			setTextSize(titlebar.getTitleTextView(), "bbs_theme0_title_txt_size");
		}
	}

	if (mainlayout == null) {
		throw new IllegalArgumentException("mainLayout is not initialized!");
	} else {
		ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(basepage.getColorId("bbs_white")));
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
			mainlayout.setBackgroundDrawable(drawable);
		} else {
			mainlayout.setBackground(drawable);
		}
	}
	basepage.setStatusBarColor(BBSViewBuilder.getInstance().getStatusBarColor(context));
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:30,代码来源:Theme0StyleModifier.java

示例4: modifyUniformWhiteStyle

import android.widget.LinearLayout; //导入方法依赖的package包/类
public static void modifyUniformWhiteStyle(BasePageWithTitle basepage) {
	if (basepage == null) {
		return;
	}
	Context context = basepage.getContext();
	TitleBar titlebar = basepage.getTitleBar();
	LinearLayout mainlayout = basepage.getMainLayout();
	if (titlebar == null) {
		throw new IllegalArgumentException("titleBar is not initialized!");
	} else {
		titlebar.setBackgroundColor(Color.TRANSPARENT);
		if(titlebar.getTitleTextView() != null) {
			titlebar.getTitleTextView().setTextColor(context.getResources().getColor(basepage.getColorId("bbs_theme1_pagetext")));
			setTextSize(titlebar.getTitleTextView(), "bbs_theme1_title_txt_size");
		}
	}

	if (mainlayout == null) {
		throw new IllegalArgumentException("mainLayout is not initialized!");
	} else {
		ColorDrawable drawable = new ColorDrawable(context.getResources().getColor(basepage.getColorId("bbs_white")));
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
			mainlayout.setBackgroundDrawable(drawable);
		} else {
			mainlayout.setBackground(drawable);
		}
	}
	basepage.setStatusBarColor(context.getResources().getColor(basepage.getColorId("bbs_theme1_statusbar")));
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:30,代码来源:Theme1StyleModifier.java

示例5: inflateToastLayout

import android.widget.LinearLayout; //导入方法依赖的package包/类
@SuppressLint("InflateParams")
private static View inflateToastLayout(CharSequence message, int type) {
    LinearLayout layout = new LinearLayout(appContext);
    LayoutInflater inflater = (LayoutInflater) appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.custom_toast_container, null);
    layout.addView(view);

    LinearLayout customToastContainer = (LinearLayout) layout.findViewById(R.id.custom_toast_container);
    ImageView icon = (ImageView) layout.findViewById(R.id.icon);
    TextView text = (TextView) layout.findViewById(R.id.text);

    switch (type) {
        case TYPE_SUCCESS:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_check_circle_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_success_background));
            break;
        case TYPE_WARNING:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_warning_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_warn_background));
            break;
        case TYPE_ERROR:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_error_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_error_background));
            break;
        default:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_info_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_info_background));
            break;
    }

    text.setText(message);

    return layout;
}
 
开发者ID:JarvanMo,项目名称:MarsBootProject,代码行数:35,代码来源:MToast.java

示例6: activateDay

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Selects the Day on position 'index'.
 * @param index
 * @param dayLayout
 * @param check: True if checkDays() should be called.
 */
private void activateDay(int index, LinearLayout dayLayout, boolean check) {
    weekdaysSelection[index] = true;

    dayLayout.setTag(true);
    Drawable bg = ContextCompat.getDrawable(getBaseContext(), R.drawable.circle_step);
    int colorPrimary = ContextCompat.getColor(getBaseContext(), R.color.accent);
    bg.setColorFilter(new PorterDuffColorFilter(colorPrimary, PorterDuff.Mode.SRC_IN));
    dayLayout.setBackground(bg);
    TextView day = (TextView) dayLayout.findViewById(R.id.day);
    day.setTextColor(ContextCompat.getColor(getBaseContext(),R.color.md_white_1000));
    if(check) {
        checkDays();
    }
}
 
开发者ID:jcolladosp,项目名称:ePills,代码行数:21,代码来源:AddPillSetTime.java

示例7: setBackground

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void setBackground(Drawable drawable)
{
           LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
	R.id.material_background);
           linearLayout.setBackground(drawable);
       }
 
开发者ID:stytooldex,项目名称:pius1,代码行数:7,代码来源:MaterialDialog.java

示例8: render

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public View render(final CoachmarkViewLayout layout) {

    if (inflated == null) {
        LayoutInflater inflater = (LayoutInflater) layout.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflated = inflater.inflate(R.layout.ok_below_description_button_view, null);
        layout.addView(inflated);
    }


    TextView mTxtOkBtn = (TextView) inflated.findViewById(R.id.txt_ok_btn);
    LinearLayout mGroupOk = (LinearLayout) inflated.findViewById(R.id.group_ok);

    mTxtOkBtn.setText(mOkText);
    mGroupOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mListener == null || mListener.onClicked()) {
                layout.dismiss();
            }
        }
    });

    if (mBorder != 0) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setStroke(mBorder, mColor != null ? mColor : ContextCompat.getColor(layout.getContext(),R.color.default_border_color));
        mGroupOk.setBackground(gradientDrawable);

    }

    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    inflated.setLayoutParams(params);


    inflated.post(new Runnable() {
        @Override
        public void run() {
            RectF descriptionRectangle = layout.calcDescriptionRect();
            inflated.setX(descriptionRectangle.centerX() - ((float) inflated.getWidth() / 2));
            inflated.setY(descriptionRectangle.bottom + inflated.getContext().getResources().getDimension(R.dimen.button_padding));
            inflated.setVisibility(View.VISIBLE);
        }
    });

    return inflated;


}
 
开发者ID:Kaufland,项目名称:andcoachmark,代码行数:49,代码来源:OkBelowDescriptionButtonRenderer.java

示例9: getView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    Project project = mProjects.get(position);
    if(convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(MBApp.getApp());
        convertView = inflater.inflate(R.layout.project_items, null);
    }

    Button appNameButton = (Button) convertView.findViewById(R.id.appNameButton);
    appNameButton.setTypeface(MBApp.getApp().getRobotoTypeface());

    ExtendedEditText appNameEdit = (ExtendedEditText) convertView.findViewById(R.id.appNameEdit);
    appNameEdit.setTypeface(MBApp.getApp().getRobotoTypeface());

    LinearLayout actionBarLayout = (LinearLayout) convertView.findViewById(R.id.actionBarForProgram);
    if(actionBarLayout != null) {
        if(project.actionBarExpanded) {
            actionBarLayout.setVisibility(View.VISIBLE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_down), null);
        } else {
            actionBarLayout.setVisibility(View.GONE);
            appNameButton.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(MBApp.getApp()
                    , R.drawable.ic_arrow_left), null);
        }
    }

    appNameButton.setText(project.name);
    appNameButton.setTag(R.id.positionId, position);
    appNameButton.setTag(R.id.textEdit, appNameEdit);
    appNameButton.setOnClickListener(appNameClickListener);
    appNameButton.setOnLongClickListener(appNameLongClickListener);

    appNameEdit.setTag(R.id.positionId, position);
    appNameEdit.setTag(R.id.editbutton, appNameButton);
    appNameEdit.setOnEditorActionListener(editorOnActionListener);
    appNameEdit.setFilters(new InputFilter[]{renameFilter});

    if(project.inEditMode) {
        appNameEdit.setVisibility(View.VISIBLE);

        appNameEdit.setText(project.name);
        appNameEdit.setSelection(project.name.length());
        appNameEdit.requestFocus();
        appNameButton.setVisibility(View.INVISIBLE);

    } else {
        appNameEdit.setVisibility(View.INVISIBLE);
        appNameButton.setVisibility(View.VISIBLE);
        //dismissKeyBoard(appNameEdit, false);
    }

    //appNameEdit.setOnClickListener(appNameClickListener);

    TextView flashBtnText = (TextView) convertView.findViewById(R.id.project_item_text);
    flashBtnText.setTypeface(MBApp.getApp().getRobotoTypeface());
    LinearLayout sendBtnLayout = (LinearLayout) convertView.findViewById(R.id.sendBtn);
    sendBtnLayout.setTag(position);
    sendBtnLayout.setOnClickListener(sendBtnClickListener);

    ImageButton deleteBtn = (ImageButton) convertView.findViewById(R.id.deleteBtn);
    deleteBtn.setTag(position);
    deleteBtn.setOnClickListener(deleteBtnClickListener);
    deleteBtn.setEnabled(true);


    Drawable myIcon;
    if(project.runStatus) {
        flashBtnText.setText("");
        myIcon = convertView.getResources().getDrawable(R.drawable.green_btn);
    } else {
        flashBtnText.setText(R.string.flash);
        myIcon = convertView.getResources().getDrawable(R.drawable.blue_btn);
    }
    sendBtnLayout.setBackground(myIcon);

    sendBtnLayout.setClickable(true);
    return convertView;
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:81,代码来源:ProjectAdapter.java


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