List of usage examples for android.view View setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.example.pagergallerysample.PagerGalleryAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View root = mInflater.inflate(R.layout.item, null); ImageView img = (ImageView) root.findViewById(R.id.item_img); Resources res = mContext.get().getResources(); int resId = res.getIdentifier("item" + (position + 1), "drawable", mContext.get().getPackageName()); img.setImageResource(resId);// w ww .ja v a2 s . c o m TextView txt = (TextView) root.findViewById(R.id.item_label); txt.setText("item " + (position + 1)); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(100, RelativeLayout.LayoutParams.MATCH_PARENT); root.setLayoutParams(lp); container.addView(root); return root; }
From source file:de.madvertise.android.sdk.MadvertiseMraidView.java
private void resize(final int width, final int height) { final FrameLayout content = (FrameLayout) getRootView().findViewById(android.R.id.content); final FrameLayout.LayoutParams adParams = new FrameLayout.LayoutParams(width, height); final View placeholderView = new View(getContext()); placeholderView.setLayoutParams(getLayoutParams()); mExpandLayout = new FrameLayout(getContext()); final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.CENTER; mExpandLayout.setLayoutParams(layoutParams); mOriginalParent = (ViewGroup) getParent(); int index = 0; if (mOriginalParent != null) { int count = mOriginalParent.getChildCount(); for (index = 0; index < count; index++) { if (mOriginalParent.getChildAt(index) == this) break; }/*from w ww . j av a 2 s . c o m*/ mIndex = index; this.setLayoutParams(adParams); mOriginalParent.removeView(this); mExpandLayout.addView(this); mCloseButton = addCloseButtonToViewGroup(((ViewGroup) getParent())); mCloseButton.setId(43); if (!mExpandProperties.useCustomClose) { mCloseButton.setImageResource(android.R.drawable.ic_menu_close_clear_cancel); } content.addView(mExpandLayout); mOriginalParent.addView(placeholderView, mIndex); mOriginalParent.setVisibility(View.GONE); mState = STATE_EXPANDED; } }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
private void addTableRowSpacer() { Context context = getActivity(); TableRow tableRow = new TableRow(context); View spacerView = new View(context); int spacerHeight = (int) (getResources().getDisplayMetrics().density * getResources().getDimension(R.dimen.network_info_spacer_height) + 0.5f); spacerView.setLayoutParams(new TableRow.LayoutParams(1, spacerHeight)); tableRow.addView(spacerView);/*w w w . j a v a 2 s. c om*/ mNetworkInfoTableLayout.addView(tableRow); }
From source file:com.nkana.app.fragment.GraphSetupFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View rootView = inflater.inflate(R.layout.fragment_graph_setup, container, false); chart = (ColumnChartView) rootView.findViewById(R.id.chart); chart.setOnValueTouchListener(new ValueTouchListener()); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); preferences = getActivity().getSharedPreferences(IConstants.AUTH_TOKEN, getActivity().MODE_PRIVATE); authKey = preferences.getString(IConstants.AUTHORIZATION, null); // getGroupsList(); generateData();/*from w ww . ja va2 s.co m*/ return rootView; }
From source file:cn.com.incito.driver.UI.detailDialog.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setLayoutParams(defaultTabLayoutParams); v.setBackgroundResource(tabBackgroundResId); if (shouldExpand) { v.setPadding(0, 0, 0, 0);/*w w w .j ava2 s. c o m*/ } else { v.setPadding(tabPadding, 0, tabPadding, 0); } if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // 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)); } } } } }
From source file:com.android.contacts.list.MultiSelectContactsListFragment.java
private void setMargins(View v, int l, int r) { if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); p.setMarginStart(l);/*from w ww.j a v a 2s . c o m*/ p.setMarginEnd(r); v.setLayoutParams(p); v.requestLayout(); } }
From source file:com.shaweibo.biu.ui.timeline.StatusDetailActivity.java
private void translateTab(int scrollY, boolean animated) { int flexibleSpaceImageHeight = getHeadViewHeight(); int tabHeight = getResources().getDimensionPixelSize(R.dimen.tab_height); View imageView = findViewById(R.id.header_toolbar); View overlayView = findViewById(R.id.overlay); overlayView.setLayoutParams( new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, flexibleSpaceImageHeight)); // Translate overlay and image float flexibleRange = flexibleSpaceImageHeight - getActionBarSize(); int minOverlayTransitionY = tabHeight - overlayView.getHeight(); ViewHelper.setTranslationY(overlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0)); ViewHelper.setTranslationY(imageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0)); // Change alpha of overlay ViewHelper.setAlpha(overlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1)); // Scale title text // float scale = 1 + ScrollUtils.getFloat((flexibleRange - scrollY - tabHeight) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA); // setPivotXToTitle(titleView); // ViewHelper.setPivotY(titleView, 0); // ViewHelper.setScaleX(titleView, scale); // ViewHelper.setScaleY(titleView, scale); // Translate title text // int maxTitleTranslationY = flexibleSpaceImageHeight - tabHeight - getActionBarSize(); // int titleTranslationY = maxTitleTranslationY - scrollY; // ViewHelper.setTranslationY(titleView, titleTranslationY); // If tabs are moving, cancel it to start a new animation. ViewPropertyAnimator.animate(mSlidingTabLayout).cancel(); // Tabs will move between the top of the screen to the bottom of the image. float translationY = ScrollUtils.getFloat(-scrollY + mFlexibleSpaceHeight - mTabHeight, 0, mFlexibleSpaceHeight - mTabHeight); if (animated) { // Animation will be invoked only when the current tab is changed. ViewPropertyAnimator.animate(mSlidingTabLayout).translationY(translationY).setDuration(200).start(); } else {//from ww w . ja v a 2 s .co m // When Fragments' scroll, translate tabs immediately (without animation). ViewHelper.setTranslationY(mSlidingTabLayout, translationY); } }
From source file:cn.qiuc.org.igoogleplay.lib.pagerslidingtab.PagerSlidingTab.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setLayoutParams(defaultTabLayoutParams); v.setBackgroundResource(tabBackgroundResId); if (shouldExpand) { v.setPadding(0, 0, 0, 0);//from ww w. j ava 2s . co m } else { v.setPadding(tabPadding, 0, tabPadding, 0); } if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor( i == 0 ? getResources().getColor(R.color.slidingtab_indicatorcolor) : tabTextColor); // 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)); } } } } }
From source file:cn.alphabets.orderbookandroid.ScrollingSidebarBehavior.java
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) { if (dependency instanceof AppBarLayout) { AppBarLayout appBarLayout = (AppBarLayout) dependency; if (appBarLayout.getTotalScrollRange() != 0) { float x = Tool.dpToPx(child, 56) * ViewCompat.getY(appBarLayout) / appBarLayout.getTotalScrollRange() + Tool.dpToPx(child, 104); CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); if (x != lp.topMargin) { lp.setMargins(lp.leftMargin, (int) x, lp.rightMargin, lp.bottomMargin); child.setLayoutParams(lp); return true; }/* w ww .j a va 2 s .com*/ } return false; } return false; }
From source file:asia.utopia.musicoff.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); v.setLayoutParams(defaultTabLayoutParams); v.setBackgroundResource(tabBackgroundResId); if (shouldExpand) { v.setPadding(0, 0, 0, 0);/*w w w . j a va 2 s .c o m*/ } else { v.setPadding(tabPadding, 0, tabPadding, 0); } if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); // 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)); } } } } }