@NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { int padding = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 16, parent.getResources().getDisplayMetrics()); TextView textView = new TextView(parent.getContext()); textView.setPadding(padding, padding, padding, padding); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); return new RecyclerView.ViewHolder(textView) { }; }
@NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { int padding = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 16, parent.getResources().getDisplayMetrics()); TextView textView = new TextView(parent.getContext()); textView.setPadding(padding, padding, padding, padding); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); return new RecyclerView.ViewHolder(textView) { }; }
@Override public View getView(int position, View convertView, ViewGroup parent) { TextView view = (TextView) super.getView(position, convertView, parent); view.setTextColor(Color.DKGRAY); view.setTag("" + position); Item item = getItem(position); if (item.type == Item.SECTION) { //view.setOnClickListener(PinnedSectionListActivity.this); view.setBackgroundColor(parent.getResources().getColor(COLORS[item.sectionPosition % COLORS.length])); } return view; }
/** * oh shit! An indicator view is badly needed! * this shit have no animation at all. */ private void initIndicators() { if (mIndicators.getChildCount() != mHeroes.size() && mHeroes.size() > 1) { mIndicators.removeAllViews(); Resources res = mIndicators.getResources(); int size = res.getDimensionPixelOffset(R.dimen.indicator_size); int margin = res.getDimensionPixelOffset(R.dimen.indicator_margin); for (int i = 0; i < getPagerCount(); i++) { ImageView indicator = new ImageView(mIndicators.getContext()); indicator.setAlpha(180); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(size, size); lp.setMargins(margin, 0, 0, 0); lp.gravity = Gravity.CENTER; indicator.setLayoutParams(lp); Drawable drawable = res.getDrawable(R.drawable.selector_indicator); indicator.setImageDrawable(drawable); mIndicators.addView(indicator); } } }
Resources resources = parent.getResources(); int size = resources.getDimensionPixelOffset(R.dimen.hero_avatar_size); int width = resources.getDimensionPixelOffset(R.dimen.hero_avatar_border);
Resources resources = parent.getResources(); int size = resources.getDimensionPixelOffset(R.dimen.hero_avatar_size); int width = resources.getDimensionPixelOffset(R.dimen.hero_avatar_border);
final int phoneDisplayHeight = contentView.getResources() .getDisplayMetrics().heightPixels; if (!isTranslucentStatus
@NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { final LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dd_debug_drawer_module_actions, parent, false); final TextView titleView = view.findViewById(R.id.dd_actions_title); titleView.setText(title); if (actions.isEmpty()) { final TextView noActionsLabel = new TextView(parent.getContext()); noActionsLabel.setTextColor(parent.getResources().getColor(android.R.color.white)); noActionsLabel.setText("No actions added"); view.addView(noActionsLabel); } else { for (Action action : actions) { view.addView(action.getView(inflater, view)); } } return view; }
/** * Inflates and binds a layout to an entry to the {@code data} variable * of the bound layout. * * @param inflater The LayoutInflater * @param parent The ViewGroup containing the list of Views * @param layoutId The layout ID to use for the list item * @param entry The data to bind to the inflated View * @return A ViewDataBinding, bound to a newly-inflated View with {@code entry} * set as the {@code data} variable. */ private static ViewDataBinding bindLayout(LayoutInflater inflater, ViewGroup parent, int layoutId, Object entry) { ViewDataBinding binding = DataBindingUtil.inflate(inflater, layoutId, parent, false); if (!binding.setVariable(BR.data, entry)) { String layoutName = parent.getResources().getResourceEntryName(layoutId); Log.w(TAG, "There is no variable 'data' in layout " + layoutName); } return binding; }
/** * Set the indicator drawable. The default is a semi-transparent circle. * * @param indicatorRes drawable resource id to be drawn indicating what the bubble actions * are acting on * @return the BubbleActions instance that called this method */ public BubbleActions withIndicator(int indicatorRes) { this.indicator = ResourcesCompat.getDrawable(root.getResources(), indicatorRes, root.getContext().getTheme()); return this; }
@Override public ViewHolder onCreateViewHolder(ViewGroup viewGroup) { mUnselectedAlpha = viewGroup.getResources() .getFraction(R.fraction.lb_browse_header_unselect_alpha, 1, 1); LayoutInflater inflater = (LayoutInflater) viewGroup.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.item_icon_header, null); return new ViewHolder(view); }
private void initializeAttributeSet(@NonNull ViewGroup parent) { sParser = parent.getResources().getLayout(R.layout.layout_params_hack); //noinspection StatementWithEmptyBody try { //noinspection StatementWithEmptyBody while (sParser.nextToken() != XmlPullParser.START_TAG) { // Skip everything until the view tag. } } catch (XmlPullParserException | IOException e) { e.printStackTrace(); } }
private ImageView createAndAddChevron(ViewGroup parent) { Resources resources = parent.getResources(); TintedDrawable chevron = TintedDrawable.constructTintedDrawable( resources, R.drawable.ic_expanded, R.color.payments_section_chevron); ImageView view = new ImageView(parent.getContext()); view.setImageDrawable(chevron); // Wrap whatever image is passed in. LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); ApiCompatibilityUtils.setMarginStart(params, mLargeSpacing); parent.addView(view, params); return view; }
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { mUnselectedAlpha = parent.getResources() .getFraction(R.fraction.lb_browse_header_unselect_alpha, 1, 1); LayoutInflater inflater = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.tv_header_item, null); view.setAlpha(mUnselectedAlpha); return new ViewHolder(view); }
public LauncherPauseAnimator(ViewGroup root) { Resources res = root.getResources(); Animator anim = new FadeAnimator(root, FadeAnimator.Direction.FADE_OUT); anim.setDuration((long) res.getInteger(R.integer.launcher_pause_animation_duration)); ((AnimatorSet) this.mDelegate).play(anim); } }
public LauncherPauseAnimator(ViewGroup root) { Resources res = root.getResources(); Animator anim = new FadeAnimator(root, FadeAnimator.Direction.FADE_OUT); anim.setDuration((long) res.getInteger(R.integer.launcher_pause_animation_duration)); ((AnimatorSet) this.mDelegate).play(anim); } }
@NonNull @Override public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { FrameLayout frameLayout = new FrameLayout(parent.getContext()); frameLayout.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); View cardDataClassView = new CardDataClassView(parent.getContext()); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, startEndPadding, parent.getResources().getDisplayMetrics()); cardDataClassView.setPadding(padding, cardDataClassView.getPaddingTop(), padding, cardDataClassView.getPaddingBottom()); frameLayout.addView(cardDataClassView); return new ViewHolder(frameLayout); }
/** * Sends an accessibility event to mMessageView announcing that this window was added so that * the mMessageView content description is read aloud if accessibility is enabled. */ void announceforAccessibility() { mMessageView.announceForAccessibility(mMessageView.getContentDescription() + mView.getResources().getString(R.string.bottom_bar_screen_position)); }
public LauncherDismissAnimator(ViewGroup root, boolean fade, View[] headers) { Builder builder = ((AnimatorSet) this.mDelegate).play(new MassSlideAnimator.Builder(root).setDirection(MassSlideAnimator.Direction.SLIDE_OUT).setFade(fade).build()); Resources res = root.getResources(); int fadeDuration = res.getInteger(R.integer.app_launch_animation_header_fade_out_duration); int fadeDelay = res.getInteger(R.integer.app_launch_animation_header_fade_out_delay); for (View header : headers) { Animator anim = new FadeAnimator(header, FadeAnimator.Direction.FADE_OUT); anim.setDuration((long) fadeDuration); anim.setStartDelay((long) fadeDelay); builder.with(anim); } } }
public LauncherDismissAnimator(ViewGroup root, boolean fade, View[] headers) { Builder builder = ((AnimatorSet) this.mDelegate).play(new MassSlideAnimator.Builder(root).setDirection(MassSlideAnimator.Direction.SLIDE_OUT).setFade(fade).build()); Resources res = root.getResources(); int fadeDuration = res.getInteger(R.integer.app_launch_animation_header_fade_out_duration); int fadeDelay = res.getInteger(R.integer.app_launch_animation_header_fade_out_delay); for (View header : headers) { Animator anim = new FadeAnimator(header, FadeAnimator.Direction.FADE_OUT); anim.setDuration((long) fadeDuration); anim.setStartDelay((long) fadeDelay); builder.with(anim); } } }