de.mrapp.android.util.ViewUtil Java Examples
The following examples show how to use
de.mrapp.android.util.ViewUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TabSwitcher.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
/** * Obtains the view's background from a specific typed array. * * @param typedArray * The typed array, the background should be obtained from, as an instance of the class * {@link TypedArray}. The typed array may not be null */ private void obtainBackground(@NonNull final TypedArray typedArray) { Drawable background = typedArray.getDrawable(R.styleable.TabSwitcher_android_background); if (background == null) { try { background = themeHelper.getDrawable(getLayout(), R.attr.tabSwitcherBackground); } catch (NotFoundException e) { // There's nothing we can do } } if (background != null) { ViewUtil.setBackground(this, background); } }
Example #2
Source File: TabletTabRecyclerAdapter.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
@NonNull @Override protected final View onInflateTabView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup parent, @NonNull final AbstractTabViewHolder viewHolder) { View view = inflater.inflate(R.layout.tablet_tab, parent, false); StateListDrawable backgroundDrawable = new StateListDrawable(); Drawable defaultDrawable = ContextCompat .getDrawable(getModel().getContext(), R.drawable.tablet_tab_background); Drawable selectedDrawable = ContextCompat .getDrawable(getModel().getContext(), R.drawable.tablet_tab_background_selected); backgroundDrawable.addState(new int[]{android.R.attr.state_selected}, selectedDrawable); backgroundDrawable.addState(StateSet.WILD_CARD, defaultDrawable); ViewUtil.setBackground(view, backgroundDrawable); return view; }
Example #3
Source File: PhoneTabRecyclerAdapter.java From ChromeLikeTabSwitcher with Apache License 2.0 | 6 votes |
@NonNull @Override protected final View onInflateTabView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup parent, @NonNull final AbstractTabViewHolder viewHolder) { View view = inflater.inflate(R.layout.phone_tab, parent, false); Drawable backgroundDrawable = ContextCompat.getDrawable(getModel().getContext(), R.drawable.phone_tab_background); ViewUtil.setBackground(view, backgroundDrawable); int padding = tabInset + tabBorderWidth; view.setPadding(padding, tabInset, padding, padding); ((PhoneTabViewHolder) viewHolder).contentContainer = view.findViewById(R.id.content_container); ((PhoneTabViewHolder) viewHolder).previewImageView = view.findViewById(R.id.preview_image_view); adaptPadding((PhoneTabViewHolder) viewHolder); ((PhoneTabViewHolder) viewHolder).borderView = view.findViewById(R.id.border_view); Drawable borderDrawable = ContextCompat.getDrawable(getModel().getContext(), R.drawable.phone_tab_border); ViewUtil.setBackground(((PhoneTabViewHolder) viewHolder).borderView, borderDrawable); return view; }
Example #4
Source File: DialogRootView.java From AndroidMaterialDialog with Apache License 2.0 | 6 votes |
/** * Creates and returns a listener, which allows to observe, when the child of the dialog's * scroll view has been layouted. If the scroll view's height is greater than necessary, its * height is reduced to match the height of its child. * * @return The listener, which has been created, as an instance of the type {@link * OnGlobalLayoutListener}. The listener may not be null */ @NonNull private OnGlobalLayoutListener createScrollViewChildLayoutListener() { return new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { View child = scrollView.getChildAt(0); int childHeight = child.getHeight(); int containerHeight = scrollView.getHeight() - scrollView.getPaddingTop() - scrollView.getPaddingBottom(); if (containerHeight > childHeight) { LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams.height = childHeight; layoutParams.weight = 0; scrollView.requestLayout(); } ViewUtil.removeOnGlobalLayoutListener(child.getViewTreeObserver(), this); } }; }
Example #5
Source File: TabSwitcherButton.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
/** * Initializes the view. */ private void initialize() { drawable = new TabSwitcherDrawable(getContext()); setImageDrawable(drawable); ViewUtil.setBackground(this, ThemeUtil.getDrawable(getContext(), R.attr.selectableItemBackgroundBorderless)); setContentDescription(null); setClickable(true); setFocusable(true); }
Example #6
Source File: AbstractTabSwitcherLayout.java From ChromeLikeTabSwitcher with Apache License 2.0 | 5 votes |
@Override public void onGlobalLayout() { ViewUtil.removeOnGlobalLayoutListener(view.getViewTreeObserver(), this); if (listener != null) { listener.onGlobalLayout(); } }
Example #7
Source File: PreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
@NonNull @CallSuper @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup parent, final Bundle savedInstanceState) { View view = super.onCreateView(inflater, parent, savedInstanceState); View listContainer = view.findViewById(AndroidResources.ANDROID_R_LIST_CONTAINER); if (!(listContainer instanceof FrameLayout)) { throw new RuntimeException( "Fragment contains a view with id 'android.R.id.list_container' that is not a FrameLayout"); } frameLayout = (FrameLayout) listContainer; buttonBarParent = (ViewGroup) inflater .inflate(R.layout.restore_defaults_button_bar, frameLayout, false); frameLayout.addView(buttonBarParent); buttonBarParent.setVisibility(showRestoreDefaultsButton ? View.VISIBLE : View.GONE); buttonBar = buttonBarParent.findViewById(R.id.restore_defaults_button_bar); ViewUtil.setBackground(buttonBar, buttonBarBackground); restoreDefaultsButton = buttonBarParent.findViewById(R.id.restore_defaults_button); restoreDefaultsButton.setOnClickListener(createRestoreDefaultsListener()); restoreDefaultsButton.setText(restoreDefaultsButtonText); shadowView = buttonBarParent.findViewById(R.id.restore_defaults_button_bar_shadow_view); shadowView.setShadowElevation(buttonBarElevation); return view; }
Example #8
Source File: NavigationPreferenceAdapter.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
@Override protected final void onVisualizePreference(@NonNull final Preference preference, @NonNull final PreferenceViewHolder viewHolder) { super.onVisualizePreference(preference, viewHolder); if (preference instanceof NavigationPreference) { NavigationPreference navigationPreference = (NavigationPreference) preference; navigationPreference.setCallback(this); boolean selected = selectedNavigationPreference == navigationPreference; ViewUtil.setBackground(viewHolder.itemView, selected ? new ColorDrawable(selectionColor) : ThemeUtil .getDrawable(preference.getContext(), R.attr.selectableItemBackground)); } }
Example #9
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 5 votes |
/** * Adapts the background color of the toolbar, which is used to show the bread crumb of the * currently selected navigation preferences, when using the split screen layout. */ private void adaptBreadCrumbBackgroundColor() { if (breadCrumbToolbar != null) { GradientDrawable background = (GradientDrawable) ContextCompat .getDrawable(this, R.drawable.breadcrumb_background); background.setColor(breadCrumbBackgroundColor); ViewUtil.setBackground(getBreadCrumbToolbar(), background); } }
Example #10
Source File: DialogRootView.java From AndroidMaterialDialog with Apache License 2.0 | 5 votes |
/** * Creates and returns a {@link OnGlobalLayoutListener}, which allows to adjust the initial * visibility of the dividers, when a view has been layouted. * * @param view The observed view as an instance of the class {@link View}. The view may not be null * @return The listener, which has been created, as an instance of the type {@link * OnGlobalLayoutListener}. The listener may not be null */ @NonNull private OnGlobalLayoutListener createScrollViewLayoutListener(@NonNull final View view) { return new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { ViewUtil.removeOnGlobalLayoutListener(view.getViewTreeObserver(), this); adaptDividerVisibilities(); } }; }
Example #11
Source File: BottomSheet.java From AndroidBottomSheet with Apache License 2.0 | 4 votes |
/** * Adapts the bottom sheet's background. */ private void adaptBackground() { if (rootView != null && background != null) { ViewUtil.setBackground(rootView, background); } }
Example #12
Source File: PreferenceFragment.java From AndroidPreferenceActivity with Apache License 2.0 | 4 votes |
/** * Adapts the background of the button bar. */ private void adaptButtonBarBackground() { if (buttonBar != null) { ViewUtil.setBackground(buttonBar, buttonBarBackground); } }
Example #13
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 4 votes |
/** * Adapts the background of the button bar. */ private void adaptButtonBarBackground() { if (buttonBar != null) { ViewUtil.setBackground(buttonBar, buttonBarBackground); } }
Example #14
Source File: PreferenceActivity.java From AndroidPreferenceActivity with Apache License 2.0 | 4 votes |
/** * Adapts the background of the navigation. */ private void adaptNavigationBackground() { if (navigationFragmentContainer != null) { ViewUtil.setBackground(navigationFragmentContainer, navigationBackground); } }