List of usage examples for android.widget FrameLayout setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:com.danielhan.neteasenews.activity.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setBackgroundResource(R.color.divider); fl.setLayoutParams(params);//www . j a v a2s . c o m final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); // v.setBackgroundResource(R.drawable.background_card); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.xwj.toolbardemo.BaseCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);//from ww w .ja va 2 s .co m fl.setBackgroundResource(drawables[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("fragment " + (position + 1)); fl.addView(v); return fl; }
From source file:com.example.toolbar.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);// w w w . j a v a2 s. c o m fl.setBackgroundResource(drawables[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); //v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.aaagame.proframework.fragment.T_PaletteFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);//from w w w . j ava 2s . com fl.setBackgroundResource(drawables[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.eric.quora.fragment.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*from w w w . ja v a2 s.co m*/ fl.setBackgroundResource(mipmaps[position]); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.BOTTOM); v.setText("CARD " + (position + 1)); fl.addView(v); return fl; }
From source file:com.example.julia.popularmovies.MovieGridActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_movie_list); ButterKnife.bind(this); mTwoPane = (findViewById(R.id.detail_fragment_framelayout) != null); // Setup Toolbar setupToolbar(savedInstanceState);/*w w w. j a v a2 s . c o m*/ // Setup ViewPager Adapter setupViewPager(mViewPager); mTabLayout.setupWithViewPager(mViewPager); // Setup Listeners to Tabs mTabLayout.addOnTabSelectedListener(this); if (mTwoPane) { FrameLayout layout = (FrameLayout) findViewById(R.id.detail_fragment_framelayout); layout.setBackgroundResource(R.drawable.detailview_placeholder); } }
From source file:com.kkbox.toolkit.app.KKTabFragment.java
protected void initView(View view, int[] buttonTextResourcetId, boolean showSubFragmentAnimation, int currentIndex) { fixStateForNestedFragment();//from w w w . j a va 2s .com initView(view); if (this.currentIndex == -1) { this.currentIndex = currentIndex; } this.showSubFragmentAnimation = showSubFragmentAnimation; radioGroup = (RadioGroup) view.findViewById(R.id.button_radiogroup); TypedValue typedValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.KKTabFragmentStyle, typedValue, true); TypedArray array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.KKTabButtonBackgroundLeft, R.attr.KKTabButtonBackgroundMiddle, R.attr.KKTabButtonBackgroundRight }); int tabButtonBackgroundLeftResourceId = array.getResourceId(0, -1); int tabButtonBackgroundMiddleResourceId = array.getResourceId(1, -1); int tabButtonBackgroundRightResourceId = array.getResourceId(2, -1); array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.KKTabBackground }); int backgroundResourceId = array.getResourceId(0, -1); FrameLayout layoutRadioBar = (FrameLayout) view.findViewById(R.id.layout_radio_bar); if (backgroundResourceId != -1) { layoutRadioBar.setBackgroundResource(backgroundResourceId); } array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.KKTabOverlay }); int overlayResourceId = array.getResourceId(0, -1); ImageView viewOverlay = (ImageView) view.findViewById(R.id.view_overlay); if (overlayResourceId != -1) { viewOverlay.setBackgroundResource(overlayResourceId); } array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { android.R.attr.textSize }); int textSize = array.getDimensionPixelSize(0, -1); array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { android.R.attr.textColor }); ColorStateList textColor = array.getColorStateList(0); array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { android.R.attr.height }); int height = array.getDimensionPixelSize(0, -1); array.recycle(); for (int i = 0; i < buttonTextResourcetId.length; i++) { RadioButton radioButton = new RadioButton(getActivity()); if (i == 0 && tabButtonBackgroundLeftResourceId != -1) { radioButton.setBackgroundResource(tabButtonBackgroundLeftResourceId); } else if (i == buttonTextResourcetId.length - 1 && tabButtonBackgroundRightResourceId != -1) { radioButton.setBackgroundResource(tabButtonBackgroundRightResourceId); } else if (tabButtonBackgroundMiddleResourceId != -1) { radioButton.setBackgroundResource(tabButtonBackgroundMiddleResourceId); } radioButton.setText(buttonTextResourcetId[i]); radioButton.setButtonDrawable(new StateListDrawable()); radioButton.setGravity(Gravity.CENTER); radioButton.setTextColor(textColor); radioButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); radioButton.setLayoutParams(new RadioGroup.LayoutParams(0, height, 1)); radioButton.setOnClickListener(buttonClickListener); radioGroup.addView(radioButton); } currentFragment = null; radioGroup.getChildAt(this.currentIndex).performClick(); }
From source file:com.gome.haoyuangong.views.MyViewPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }//from ww w . java 2s .c o m mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final View child = mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); } FrameLayout f = (FrameLayout) child.findViewWithTag("framelayout"); if (i == item) { //f.setBackgroundResource(R.drawable.icon_tab_focus); } else { f.setBackgroundResource(0); } } }
From source file:com.projecty.sleepgroundbox.activity.HomeActivity.java
private void setLayoutBackgroundColor(int layout_id) { for (FrameLayout layout : layoutList) { layout.setBackgroundResource(R.color.drawer_background); }/* w w w . jav a 2s . c om*/ layoutList.get(layout_id).setBackgroundResource(R.color.theme_color2); }
From source file:com.example.guxiuzhong.pagerslidingtab_lib.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { FrameLayout frameLayout = (FrameLayout) tabsContainer.getChildAt(i); frameLayout.setBackgroundResource(tabBackgroundResId); for (int j = 0; j < frameLayout.getChildCount(); j++) { View v = frameLayout.getChildAt(j); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (j == 0) { tab.setTextColor(tabTextColor); } else { tab.setTextColor(selectedTabTextColor); }/*from ww w. j a v a 2s .c o m*/ ViewHelper.setAlpha(tabViews.get(i).get("normal"), 1); ViewHelper.setAlpha(tabViews.get(i).get("selected"), 0); //set normal Scale ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f); ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f); ViewHelper.setScaleX(frameLayout, 1f); ViewHelper.setScaleY(frameLayout, 1f); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } if (i == selectedPosition) { ViewHelper.setAlpha(tabViews.get(i).get("normal"), 0); ViewHelper.setAlpha(tabViews.get(i).get("selected"), 1); //set select Scale ViewHelper.setPivotX(frameLayout, frameLayout.getMeasuredWidth() * 0.5f); ViewHelper.setPivotY(frameLayout, frameLayout.getMeasuredHeight() * 0.5f); ViewHelper.setScaleX(frameLayout, 1 + zoomMax); ViewHelper.setScaleY(frameLayout, 1 + zoomMax); } } } } }