List of usage examples for android.view ViewGroup getResources
public Resources getResources()
From source file:Main.java
public static int getHeightForDp(ViewGroup parent, float dp) { DisplayMetrics metrics = parent.getResources().getDisplayMetrics(); float fpixels = metrics.density * dp; return (int) (fpixels + 0.5f); }
From source file:Main.java
/** * Hack since we don't have access to the private * android.support.design.widget.AppBarLayout.getTopInset() method *//*w w w . j a v a2s .c o m*/ public static int getTopInset(ViewGroup appBarLayout) { int inset = 0; int resourceId = appBarLayout.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (ViewCompat.getFitsSystemWindows(appBarLayout) && resourceId > 0) { inset = appBarLayout.getResources().getDimensionPixelSize(resourceId); } return inset; }
From source file:com.google.android.leanbackjank.presenter.HeaderItemPresenter.java
@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.header_item, null); view.setAlpha(mUnselectedAlpha); // Initialize icons to be at half-opacity. return new ViewHolder(view); }
From source file:org.amahi.anywhere.tv.presenter.IconHeaderPresenter.java
@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);//from w ww .j a v a2 s . c o m return new ViewHolder(view); }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Sets the line and fill colors for real-time indicator circles contained in the provided * realtime_indicator.xml layout. There are several circles, so each needs to be set * individually. The resource code for the color to be used should be provided. * * @param vg realtime_indicator.xml layout * @param lineColor resource code color to be used as line color, or null to use the default * colors/* w ww . ja v a2 s.c o m*/ * @param fillColor resource code color to be used as fill color, or null to use the default * colors */ public static void setRealtimeIndicatorColorByResourceCode(ViewGroup vg, Integer lineColor, Integer fillColor) { Resources r = vg.getResources(); setRealtimeIndicatorColor(vg, r.getColor(lineColor), r.getColor(fillColor)); }
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. j a v a 2s. co 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.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 w w w. j a v 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:org.uoyabause.android.tv.CardPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background); sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background); mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie); ImageCardView cardView = new ImageCardView(parent.getContext()) { @Override/*from w w w.ja va2s. c om*/ public void setSelected(boolean selected) { updateCardBackgroundColor(this, selected); super.setSelected(selected); } }; cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); updateCardBackgroundColor(cardView, false); return new ViewHolder(cardView); }
From source file:com.google.android.leanbackjank.presenter.CardPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { mDefaultBackgroundColor = ResourcesCompat.getColor(parent.getResources(), R.color.jank_blue, null); mSelectedBackgroundColor = ResourcesCompat.getColor(parent.getResources(), R.color.jank_red, null); ImageCardView cardView = new ImageCardView(parent.getContext()) { @Override/*ww w . jav a 2s. c om*/ public void setSelected(boolean selected) { findViewById(R.id.info_field) .setBackgroundColor(selected ? mSelectedBackgroundColor : mDefaultBackgroundColor); super.setSelected(selected); } }; cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); return new ViewHolder(cardView); }
From source file:home.ned.lul.CardPresenter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent) { Log.d(TAG, "onCreateViewHolder"); sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background); sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background); mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie); ImageCardView cardView = new ImageCardView(parent.getContext()) { @Override/* www. j a va 2s . c o m*/ public void setSelected(boolean selected) { updateCardBackgroundColor(this, selected, 0); super.setSelected(selected); } }; cardView.setFocusable(true); cardView.setFocusableInTouchMode(true); updateCardBackgroundColor(cardView, false, 0); return new ViewHolder(cardView); }