List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:Main.java
public static void collapse(final ViewGroup v) { final int initialHeight = v.getMeasuredHeight(); Animation a = new Animation() { @Override// w ww . j a v a 2 s. c o m protected void applyTransformation(float interpolatedTime, Transformation t) { if (interpolatedTime == 1) { v.setVisibility(View.GONE); } else { v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime); v.setAlpha(1 - interpolatedTime); v.requestLayout(); } } @Override public boolean willChangeBounds() { return true; } }; a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:android.support.transition.ViewOverlay.java
public static ViewOverlay createFrom(View view) { ViewGroup contentView = getContentView(view); if (contentView != null) { final int numChildren = contentView.getChildCount(); for (int i = 0; i < numChildren; ++i) { View child = contentView.getChildAt(i); if (child instanceof OverlayViewGroup) { return ((OverlayViewGroup) child).mViewOverlay; }/*from ww w. jav a 2 s . c o m*/ } return new ViewGroupOverlay(contentView.getContext(), contentView, view); } return null; }
From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java
public static ViewDragHelper create(ViewGroup forParent, Callback cb) { return new ViewDragHelper(forParent.getContext(), forParent, null, cb); }
From source file:Main.java
public static void expand(final ViewGroup v) { v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); // Older versions of android (pre API 21) cancel animations for views with a height of 0. v.getLayoutParams().height = 1;/* ww w. jav a 2 s. co m*/ v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? ViewGroup.LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.setAlpha(interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:com.hynet.mergepay.components.widget.panellayout.ViewDragHelper.java
public static ViewDragHelper create(ViewGroup forParent, Interpolator interpolator, Callback cb) { return new ViewDragHelper(forParent.getContext(), forParent, interpolator, cb); }
From source file:com.scooter1556.sms.android.presenter.SettingsItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT)); view.setFocusable(true);//w ww . ja v a2s . c om view.setFocusableInTouchMode(true); view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.primary)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:com.google.android.leanbackjank.presenter.GridItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); Resources res = parent.getResources(); int width = res.getDimensionPixelSize(R.dimen.grid_item_width); int height = res.getDimensionPixelSize(R.dimen.grid_item_height); view.setLayoutParams(new ViewGroup.LayoutParams(width, height)); view.setFocusable(true);/*from ww w .ja va 2s . c o m*/ view.setFocusableInTouchMode(true); view.setBackgroundColor(ResourcesCompat.getColor(parent.getResources(), R.color.jank_yellow, null)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:com.scooter1556.sms.androidtv.presenter.MediaFolderPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT)); view.setFocusable(true);//from w ww. j av a 2 s . c o m view.setFocusableInTouchMode(true); view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:com.aengbee.android.leanback.presenter.GridItemPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { TextView view = new TextView(parent.getContext()); Resources res = parent.getResources(); int width = res.getDimensionPixelSize(R.dimen.grid_item_width); int height = res.getDimensionPixelSize(R.dimen.grid_item_height); view.setLayoutParams(new ViewGroup.LayoutParams(width, height)); view.setFocusable(true);/*from ww w. j a va 2 s .co m*/ view.setFocusableInTouchMode(true); view.setBackgroundColor(ContextCompat.getColor(parent.getContext(), R.color.default_background)); view.setTextColor(Color.WHITE); view.setGravity(Gravity.CENTER); return new ViewHolder(view); }
From source file:MainAdapter.java
@Override public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_main, parent, false); v.setOnClickListener(MainActivity.mainOnClickListener); return new MainViewHolder(v); }