List of usage examples for android.view ViewGroup getBackground
public Drawable getBackground()
From source file:com.auth0.android.lock.views.CountryCodeSelectorView.java
private void setupBackground() { Drawable leftBackground = ViewUtils.getRoundedBackground(getResources(), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal), ViewUtils.Corners.ONLY_LEFT); Drawable rightBackground = ViewUtils.getRoundedBackground(getResources(), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_country_code_background), ViewUtils.Corners.ONLY_RIGHT); ViewUtils.setBackground(icon, leftBackground); ViewUtils.setBackground(chevron, rightBackground); ViewGroup parent = ((ViewGroup) countryNameTextView.getParent()); Drawable bg = parent.getBackground(); GradientDrawable gd = bg == null ? new GradientDrawable() : (GradientDrawable) bg; gd.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius)); gd.setStroke(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal)); gd.setColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal)); ViewUtils.setBackground(parent, gd); }
From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java
public void attachToActivity(Activity activity, boolean isFloatActionBarEnabled) { // get the window background TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); int background = a.getResourceId(0, 0); a.recycle();/*from w ww . j av a 2 s . c o m*/ this.isFloatActionBarEnabled = isFloatActionBarEnabled; if (isFloatActionBarEnabled) { ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); if (decorChild.getBackground() != null) { this.setBackgroundDrawable(decorChild.getBackground()); decorChild.setBackgroundDrawable(null); } else { if (this.getBackground() == null) this.setBackgroundResource(background); } decor.removeView(decorChild); decor.addView(this, 0); getContentView().addView(decorChild); } else { ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content); ViewGroup content = (ViewGroup) contentParent.getChildAt(0); contentParent.removeView(content); contentParent.addView(this, 0); getContentView().addView(content); } }
From source file:mobi.cangol.mobile.navigation.SlidingMenuLayout.java
public void attachToActivity(Activity activity, boolean isFloatActionBarEnabled) { // get the window background TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); int background = a.getResourceId(0, 0); a.recycle();/* w ww . ja v a 2 s . com*/ this.isFloatActionBarEnabled = isFloatActionBarEnabled; if (isFloatActionBarEnabled) { ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView(); ViewGroup decorChild = (ViewGroup) decor.getChildAt(0); if (decorChild.getBackground() != null) { this.setBackgroundDrawable(decorChild.getBackground()); decorChild.setBackgroundDrawable(null); } else { if (this.getBackground() == null) this.setBackgroundResource(background); } decor.removeView(decorChild); decor.addView(this.getRootView(), 0); getContentView().addView(decorChild); } else { ViewGroup contentParent = (ViewGroup) activity.findViewById(android.R.id.content); ViewGroup content = (ViewGroup) contentParent.getChildAt(0); contentParent.removeView(content); contentParent.addView(this, 0); getContentView().addView(content); } }
From source file:com.auth0.android.lock.views.ValidatedInputView.java
/** * Updates the view knowing if the input is valid or not. * * @param isValid if the input is valid or not for this kind of DataType. *//*from w ww .ja v a2 s.c o m*/ @CallSuper protected void updateBorder(boolean isValid) { ViewGroup parent = ((ViewGroup) input.getParent()); Drawable bg = parent.getBackground(); GradientDrawable gd = bg == null ? new GradientDrawable() : (GradientDrawable) bg; gd.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius)); int strokeColor = isValid ? R.color.com_auth0_lock_input_field_border_normal : R.color.com_auth0_lock_input_field_border_error; gd.setStroke(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), strokeColor)); gd.setColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal)); ViewUtils.setBackground(parent, gd); errorDescription.setVisibility(isValid ? INVISIBLE : VISIBLE); requestLayout(); }
From source file:com.example.administrator.mywebviewdrawsign.SysWebView.java
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) { // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0 LogUtils.d("showing Custom View"); // if a view already exists then immediately terminate the new one if (mCustomView != null) { callback.onCustomViewHidden();/*w w w .j ava2 s . c o m*/ return; } // Store the view and its callback for later (to kill it properly) mCustomView = view; mCustomViewCallback = callback; // Add the custom view to its container. ViewGroup parent = (ViewGroup) this.getParent(); background = parent.getBackground(); parent.setBackground(new ColorDrawable(Color.BLACK)); parent.addView(view, COVER_SCREEN_GRAVITY_CENTER); // Hide the content view. this.setVisibility(View.GONE); // Finally show the custom view container. parent.setVisibility(View.VISIBLE); parent.bringToFront(); if (objects != null && objects.length > 0) { for (Object obj : objects) { if (obj instanceof View) { ((View) obj).setVisibility(View.GONE); } else if (obj instanceof Fragment) { ((Fragment) obj).getView().setVisibility(View.GONE); } } } ((Activity) mContext).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); ((Activity) mContext).getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
From source file:org.chromium.chrome.browser.compositor.CompositorViewHolder.java
@Override public void onSwapBuffersCompleted(int pendingSwapBuffersCount) { TraceEvent.instant("onSwapBuffersCompleted"); // Wait until the second frame to turn off the placeholder background on // tablets so the tab strip has time to start drawing. final ViewGroup controlContainer = (ViewGroup) mControlContainer; if (controlContainer != null && controlContainer.getBackground() != null && mHasDrawnOnce) { post(new Runnable() { @Override//from w w w . j a v a 2 s . c o m public void run() { controlContainer.setBackgroundResource(0); } }); } mHasDrawnOnce = true; mPendingSwapBuffersCount = pendingSwapBuffersCount; if (!mSkipInvalidation || pendingSwapBuffersCount == 0) flushInvalidation(); mSkipInvalidation = !mSkipInvalidation; }
From source file:org.onebusaway.android.ui.TripDetailsListFragment.java
private void setUpHeader() { ObaTripStatus status = mTripInfo.getStatus(); ObaReferences refs = mTripInfo.getRefs(); Context context = getActivity(); String tripId = mTripInfo.getId(); ObaTrip trip = refs.getTrip(tripId); ObaRoute route = refs.getRoute(trip.getRouteId()); TextView shortName = (TextView) getView().findViewById(R.id.short_name); shortName.setText(route.getShortName()); TextView longName = (TextView) getView().findViewById(R.id.long_name); longName.setText(trip.getHeadsign()); TextView agency = (TextView) getView().findViewById(R.id.agency); agency.setText(refs.getAgency(route.getAgencyId()).getName()); TextView vehicleView = (TextView) getView().findViewById(R.id.vehicle); TextView vehicleDeviation = (TextView) getView().findViewById(R.id.status); ViewGroup realtime = (ViewGroup) getView().findViewById(R.id.eta_realtime_indicator); realtime.setVisibility(View.GONE); ViewGroup statusLayout = (ViewGroup) getView().findViewById(R.id.status_layout); if (status == null) { // Show schedule info only vehicleView.setText(null);//from w ww . j a va 2 s .c om vehicleView.setVisibility(View.GONE); vehicleDeviation.setText(context.getString(R.string.trip_details_scheduled_data)); return; } if (!TextUtils.isEmpty(status.getVehicleId())) { // Show vehicle info vehicleView.setText(context.getString(R.string.trip_details_vehicle, status.getVehicleId())); vehicleView.setVisibility(View.VISIBLE); } else { vehicleView.setVisibility(View.GONE); } // Set status color in header statusLayout.setBackgroundResource(R.drawable.round_corners_style_b_header_status); GradientDrawable d = (GradientDrawable) statusLayout.getBackground(); int statusColor; if (!status.isPredicted()) { // We have only schedule info, but the bus position can still be interpolated vehicleDeviation.setText(context.getString(R.string.trip_details_scheduled_data)); statusColor = R.color.stop_info_scheduled_time; d.setColor(getResources().getColor(statusColor)); return; } /** * We have real-time info */ realtime.setVisibility(View.VISIBLE); long deviation = status.getScheduleDeviation(); long deviationMin = TimeUnit.SECONDS.toMinutes(status.getScheduleDeviation()); long minutes = Math.abs(deviation) / 60; long seconds = Math.abs(deviation) % 60; String lastUpdate = DateUtils.formatDateTime(getActivity(), status.getLastUpdateTime(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT); statusColor = ArrivalInfo.computeColorFromDeviation(deviationMin); if (statusColor != R.color.stop_info_ontime) { // Show early/late/scheduled color d.setColor(getResources().getColor(statusColor)); } else { // For on-time, use header default color d.setColor(getResources().getColor(R.color.theme_primary)); } if (deviation >= 0) { if (deviation < 60) { vehicleDeviation .setText(context.getString(R.string.trip_details_real_time_sec_late, seconds, lastUpdate)); } else { vehicleDeviation.setText(context.getString(R.string.trip_details_real_time_min_sec_late, minutes, seconds, lastUpdate)); } } else { if (deviation > -60) { vehicleDeviation .setText(context.getString(R.string.trip_details_real_time_sec_early, seconds, lastUpdate)); } else { vehicleDeviation.setText(context.getString(R.string.trip_details_real_time_min_sec_early, minutes, seconds, lastUpdate)); } } }
From source file:com.juick.android.MainActivity.java
private static void restyleViewGroup(ViewGroup view, ColorsTheme.ColorTheme colorTheme, boolean pressed, boolean selected, boolean dontBackground) { ViewGroup parent = view;//from ww w . ja v a 2 s . c o m if (parent.getId() == R.id.navigation_panel) return; int childCount = parent.getChildCount(); int background = colorTheme.getBackground(pressed); int foreground = colorTheme.getForeground(pressed); if (selected) { background = calculatePressedBackground(background, foreground); } if (!dontBackground) { boolean skipDraw = false; if ((view instanceof LinearLayout || view instanceof FrameLayout || view instanceof RelativeLayout)) { Context context = view.getContext(); if (context instanceof MainActivity || context instanceof MessagesActivity || context instanceof ThreadActivity) { // no unneeded background in given scrolling activities skipDraw = true; if (view.getBackground() != null) { // but enable for layouts that with color skipDraw = false; } if (!skipDraw && view.getClass().getName().toLowerCase().contains("decorview")) { // given activities manage themselves skipDraw = true; } } } if (!skipDraw) parent.setBackgroundColor(background); } if (view instanceof ListView) dontBackground = true; for (int i = 0; i < childCount; i++) { View child = parent.getChildAt(i); restyleChildrenOrWidget(child, dontBackground); } }