本文整理匯總了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));
}
}
}
示例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")));
}
示例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));
}
示例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")));
}
示例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;
}
示例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();
}
}
示例7: setBackground
import android.widget.LinearLayout; //導入方法依賴的package包/類
public void setBackground(Drawable drawable)
{
LinearLayout linearLayout = (LinearLayout) mAlertDialogWindow.findViewById(
R.id.material_background);
linearLayout.setBackground(drawable);
}
示例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;
}
示例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;
}