Refine search
Snackbar snackbar; snackbar = Snackbar.make(view, "Message", Snackbar.LENGTH_SHORT); View snackBarView = snackbar.getView(); snackBarView.setBackgroundColor(yourColor); TextView textView = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_text); textView.setTextColor(textColor); snackbar.show();
@NonNull @Override protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { Log.i(TAG, "Conductor: onCreateView() called"); View view = inflater.inflate(R.layout.controller_lifecycle, container, false); view.setBackgroundColor(ContextCompat.getColor(container.getContext(), R.color.orange_300)); unbinder = ButterKnife.bind(this, view); tvTitle.setText(getResources().getString(R.string.rxlifecycle_title, TAG)); return view;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.usersettings_fragment, container, false); loginButton = (LoginButton) view.findViewById(R.id.usersettings_fragment_login_button); loginButton.setFragment(this); connectedStateLabel = (TextView) view.findViewById(R.id.usersettings_fragment_profile_name); // if no background is set for some reason, then default to Facebook blue if (view.getBackground() == null) { view.setBackgroundColor(getResources().getColor(R.color.facebook_blue)); } else { view.getBackground().setDither(true); return view;
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.usersettings_fragment, container, false); loginButton = (LoginButton) view.findViewById(R.id.usersettings_fragment_login_button); loginButton.setFragment(this); connectedStateLabel = (TextView) view.findViewById(R.id.usersettings_fragment_profile_name); // if no background is set for some reason, then default to Facebook blue if (view.getBackground() == null) { view.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue)); } else { view.getBackground().setDither(true); return view;
Snackbar snackbar = Snackbar .make(parentLayout, R.string.snackbar_text, Snackbar.LENGTH_LONG) .setAction(R.string.snackbar_action, myOnClickListener); snackbar.setActionTextColor(Color.CYAN); View snackbarView = snackbar.getView(); snackbarView.setBackgroundColor(Color.YELLOW);//change Snackbar's background color; TextView textView = (TextView)snackbarView .findViewById(android.support.design.R.id.snackbar_text); textView.setTextColor(Color.BLUE);//change Snackbar's text color; snackbar.show(); // Don’t forget to show!
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); mContentView = inflater.inflate(getContentView(), container, false); mContentView.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white)); return mContentView;
@Override public Object instantiateItem(ViewGroup container, int position) { View page= getLayoutInflater().inflate(R.layout.page, container, false); TextView tv=page.findViewById(R.id.text); int blue=position * 25; final String msg= String.format(getString(R.string.item), position + 1); tv.setText(msg); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG) .show(); page.setBackgroundColor(Color.argb(255, 0, 0, blue)); container.addView(page); return(page);
@Override public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) { View star = child.findViewById(R.id.star); float d = child.getHeight() / 2 - star.getHeight() / 2; ViewHelper.setTranslationY(star, d * fraction); ViewHelper.setScaleX(star, fraction + 0.6f); ViewHelper.setScaleY(star, fraction + 0.6f); int c = (Integer) evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#4C535B")); child.setBackgroundColor(c);
private void initView() {
LayoutInflater.from(getContext()).inflate(R.layout.layout_title_view, this, true);
this.setOrientation(VERTICAL);
this.setBackgroundColor(titleBackgroundColor);
TextView titleTextView = (TextView) findViewById(R.id.title_text_view);
titleTextView.setText(title);
// titleTextView.setTextSize(titleTextSize);
titleTextView.setTextColor(titleTextColor);
View view = findViewById(R.id.title_line_view);
view.setBackgroundColor(titleLineColor);
private View getContainer(View rootView) {
rootView.setBackgroundColor(getResources().getColor(R.color.alpha_white));
View container = getLayoutInflater().inflate(R.layout.activity_base, null, false);
SwipeBackLayout swipeBackLayout = (SwipeBackLayout) container.findViewById(R.id.swipeBackLayout);
View ivShadow = container.findViewById(R.id.iv_shadow);
swipeBackLayout.addView(rootView);
swipeBackLayout.setOnScroll((fs) -> ivShadow.setAlpha(1 - fs));
return container;
private void initiateRootViews(View view) {
mUCropView = view.findViewById(R.id.ucrop);
mGestureCropImageView = mUCropView.getCropImageView();
mOverlayView = mUCropView.getOverlayView();
mGestureCropImageView.setTransformImageListener(mImageListener);
((ImageView) view.findViewById(R.id.image_view_logo)).setColorFilter(mLogoColor, PorterDuff.Mode.SRC_ATOP);
view.findViewById(R.id.ucrop_frame).setBackgroundColor(mRootViewBackgroundColor);
/**
* This gets called when each new ViewHolder is created. This happens when the RecyclerView
* is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling.
* @param viewGroup The ViewGroup that these ViewHolders are contained within.
* @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you
* can use this viewType integer to provide a different layout. See
* {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)}
* for more details.
* @return A new NumberViewHolder that holds the View for each list item
@Override
public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
Context context = viewGroup.getContext();
int layoutIdForListItem = R.layout.number_list_item;
LayoutInflater inflater = LayoutInflater.from(context);
boolean shouldAttachToParentImmediately = false;
View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately);
NumberViewHolder viewHolder = new NumberViewHolder(view);
viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount);
int backgroundColorForViewHolder = ColorUtils
.getViewHolderBackgroundColorFromInstance(context, viewHolderCount);
viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder);
viewHolderCount++;
Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: "
+ viewHolderCount);
return viewHolder;
view = convertView;
} else {
view = mLayoutInflater.inflate(R.layout.choose_account_item, parent, false);
AccountHolder holder = new AccountHolder();
holder.name = view.findViewById(R.id.name);
holder.chip = view.findViewById(R.id.chip);
view.setTag(holder);
AccountHolder holder = (AccountHolder) view.getTag();
holder.name.setText(account.getDescription());
holder.chip.setBackgroundColor(account.getChipColor());
} else if (item instanceof IdentityContainer) {
if (convertView != null && convertView.getTag() instanceof IdentityHolder) {
view = convertView;
} else {
view = mLayoutInflater.inflate(R.layout.choose_identity_item, parent, false);
IdentityHolder holder = new IdentityHolder();
holder.name = view.findViewById(R.id.name);
holder.description = view.findViewById(R.id.description);
view.setTag(holder);
/** * 显示下载 Snackbar * @param activity * @param message * @param isLong public static void showDownloadSnackbar(final Activity activity, String message, boolean isLong) { if (activity == null) { return; View view = activity.getWindow().getDecorView().findViewById(android.R.id.content); Snackbar snackbar = Snackbar.make(view, message, isLong ? Snackbar.LENGTH_LONG : Snackbar.LENGTH_SHORT); View snackbarView = snackbar.getView(); if (snackbarView != null) { snackbarView.setBackgroundColor(ContextCompat.getColor(activity, R.color.snackbar_bg)); snackbar.setAction("查看任务>", new View.OnClickListener() { @Override public void onClick(View v) { DownloadActivity.launch(activity, 1); }).show();
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if(v == null) { v = LayoutInflater.from(MainActivity.this).inflate(R.layout.row_drawer, null); v.setOnClickListener(this); v.setTag(position); Tab tab = (Tab)getItem(position); ((TextView)v).setText(tab.toString()); if(tab == mSelectedTab) { v.setBackgroundColor(ThemeManager.getInstance().getCurrentTheme() == 0 ? mBackgroundColorLight : mBackgroundColorDark); ((TextView)v).setTextColor(0xFFFFFFFF); else { v.setBackgroundResource(0); ((TextView)v).setTextColor(ThemeManager.getInstance().getCurrentTheme() == 0 ? mTextColorLight : mTextColorDark); return v;
LayoutInflater inflater = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.dialog_color_picker, null);
layout.setBackgroundColor(Color.WHITE);
setView(layout);
.findViewById(R.id.color_picker_view);
mOldColor = (ColorPanelView) layout.findViewById(R.id.old_color_panel);
mNewColor = (ColorPanelView) layout.findViewById(R.id.new_color_panel);
@Override protected void onViewBound(@NonNull View view) { super.onViewBound(view);