@Override protected void onBindViewHolder(SmartViewHolder holder, Object model, int position) { int[] colorIds = { R.color.colorPrimaryDark, android.R.color.holo_green_dark, android.R.color.holo_red_dark, android.R.color.holo_orange_dark, }; holder.itemView.setBackgroundResource(colorIds[random.nextInt(colorIds.length)]); holder.itemView.setMinimumWidth(DensityUtil.dp2px(70f + random.nextInt(70))); } @NonNull
Activity activity = ...; AlertDialog dialog = ...; // retrieve display dimensions Rect displayRectangle = new Rect(); Window window = activity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); // inflate and adjust layout LayoutInflater inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.your_dialog_layout, null); layout.setMinimumWidth((int)(displayRectangle.width() * 0.9f)); layout.setMinimumHeight((int)(displayRectangle.height() * 0.9f)); dialog.setView(layout);
rootView.setOnTouchListener(listener); playerImpl.getLoadingPanel().setMinimumWidth(popupLayoutParams.width); playerImpl.getLoadingPanel().setMinimumHeight(popupLayoutParams.height); windowManager.addView(rootView, popupLayoutParams);
@SuppressWarnings("DrawAllocation") @Override protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) { final int width = MeasureSpec.getSize(widthMeasureSpec); switch (measureState) { case FINISH_AWAIT: break; case AWAIT: break; case FINISH: viewportView.setMinimumWidth(width); viewportView.setMinimumHeight(layout.getMeasuredHeight()); measureState = MeasureTaskState.FINISH_AWAIT; if(cacheConfig != CacheConfig.NO_CACHE){ allocateResources(); } break; case START: if (measureTask != null) { measureTask.cancel(true); measureTask = null; } measureTask = new MeasureTask(width); measureTask.execute(); measureState = MeasureTaskState.AWAIT; break; } super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
v.setMinimumHeight(a.getDimensionPixelSize(attr, 0)); else if(attr == R.styleable.View_android_minWidth) v.setMinimumWidth(a.getDimensionPixelSize(attr, 0)); else if(attr == R.styleable.View_android_requiresFadingEdge) v.setVerticalFadingEdgeEnabled(a.getBoolean(attr, true));
@Override public void setDimension(V view, float dimension) { view.setMinimumWidth((int) dimension); } });
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.your_fragment_layout, container); Rect displayRectangle = new Rect(); Window window = getDialog().getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); v.setMinimumWidth((int)(displayRectangle.width() * 0.9f)); v.setMinimumHeight((int)(displayRectangle.height() * 0.9f)); return v; }
@Override public SubActivityViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = inflater.inflate(R.layout.custom_card, parent, false); view.setMinimumWidth(parent.getMeasuredWidth()); SubActivityViewHolder subActivityViewHolder = new SubActivityViewHolder(view); return subActivityViewHolder; }
public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { convertView = new ImageView(context); convertView.setMinimumHeight(32); convertView.setMinimumWidth(32); } ((ImageView)convertView).setImageDrawable(new ColorDrawable((int) getItem(position))); return convertView; }
@Override public View createTabContent(String tag) { View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }
@Override public View createTabContent(String tag) { View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }
@Override public View createTabContent(final String tag) { final View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }
@Override public View createTabContent(String tag) { View v = new View(mContext); v.setMinimumWidth(0); v.setMinimumHeight(0); return v; } }
Rect displayRectangle = new Rect(); Window window = this.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); LayoutInflater inflater = LayoutInflater.from(this); View builderView = inflater.inflate(R.layout.activity_dia, null); builderView.setMinimumWidth((int) (displayRectangle.width() * 0.9f)); builderView.setMinimumHeight((int) (displayRectangle.height() * 0.9f)); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(builderView); AlertDialog alert = builder.create(); alert.show();
public void run(RapidParserObject object, Object view, Var value) { ((View)view).setMinimumWidth(ViewUtils.dip2px(((View)view).getContext(), value.getFloat())); } }
int dips = 70; // The min width you want in DIP int pixels = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dips, getResources().getDisplayMetrics()); TabWidget widget = tabHost.getTabWidget(); for (int i = 0; i < widget.getChildCount(); ++i) { View v = widget.getChildAt(i); v.setMinimumWidth(pixels); } }
private void updateTabViews(final boolean requestLayout) { for (int i = 0; i < mTabStrip.getChildCount(); i++) { View child = mTabStrip.getChildAt(i); child.setMinimumWidth(getTabMinWidth()); updateTabViewLayoutParams((LinearLayout.LayoutParams) child.getLayoutParams()); if (requestLayout) { child.requestLayout(); } } }
public void bind(String title) { titleView.setText(title); itemView.setSelected(selectedPosition == getAdapterPosition()); if (randomWidth) { itemView.setMinimumWidth(getRandomSize()); } if (randomHeight) { itemView.setMinimumHeight(getRandomSize()); } }
void updateTabViews(final boolean requestLayout) { for (int i = 0; i < mTabStrip.getChildCount(); i++) { View child = mTabStrip.getChildAt(i); child.setMinimumWidth(getTabMinWidth()); updateTabViewLayoutParams((LinearLayout.LayoutParams) child.getLayoutParams()); if (requestLayout) { child.requestLayout(); } } }
@Override public void updatePadding(CardViewDelegate cardView) { Rect shadowPadding = new Rect(); getShadowBackground(cardView).getMaxShadowAndCornerPadding(shadowPadding); ((View) cardView).setMinimumHeight((int) Math.ceil(getMinHeight(cardView))); ((View) cardView).setMinimumWidth((int) Math.ceil(getMinWidth(cardView))); cardView.setShadowPadding(shadowPadding.left, shadowPadding.top, shadowPadding.right, shadowPadding.bottom); }