Example usage for android.view View setLayoutParams

List of usage examples for android.view View setLayoutParams

Introduction

In this page you can find the example usage for android.view View setLayoutParams.

Prototype

public void setLayoutParams(ViewGroup.LayoutParams params) 

Source Link

Document

Set the layout parameters associated with this view.

Usage

From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_session_detail, null);

    mTitle = (TextView) mRootView.findViewById(R.id.session_title);
    mSubtitle = (TextView) mRootView.findViewById(R.id.session_subtitle);

    // Larger target triggers plus one button
    View headerView = mRootView.findViewById(R.id.header_session);
    mAbstract = (TextView) mRootView.findViewById(R.id.session_abstract);
    mRequirements = (TextView) mRootView.findViewById(R.id.session_requirements);

    mAddScheduleButton = (CheckableLinearLayout) mRootView.findViewById(R.id.add_schedule_button);
    mAddScheduleButton.setOnClickListener(new OnClickListener() {
        @Override// w ww  .j  av  a 2 s  .  c  om
        public void onClick(View view) {
            setSessionStarred(!mStarred, true);
        }
    });
    mAddScheduleButton.setVisibility(View.GONE);

    if (mVariableHeightHeader) {
        ViewGroup.LayoutParams layoutParams = headerView.getLayoutParams();
        layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        headerView.setLayoutParams(layoutParams);
    }

    setupCustomScrolling(mRootView);

    return mRootView;
}

From source file:com.hdit.wldemo.widget.SlidingTabLayoutTest.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;//from  w  ww  .j a  v a 2 s . co  m

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        mItemName = (TabItemName) adapter;
        tabTitleView.setText(mItemName.getTabName(i));
        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT,
                1.0f);
        tabView.setLayoutParams(layoutParams);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }
    }
}

From source file:android.support.v7.app.MediaRouteControllerDialog.java

private void updateVolumeGroupItemHeight(View item) {
    LinearLayout container = (LinearLayout) item.findViewById(R.id.volume_item_container);
    setLayoutHeight(container, mVolumeGroupListItemHeight);
    View icon = item.findViewById(R.id.mr_volume_item_icon);
    ViewGroup.LayoutParams lp = icon.getLayoutParams();
    lp.width = mVolumeGroupListItemIconSize;
    lp.height = mVolumeGroupListItemIconSize;
    icon.setLayoutParams(lp);
}

From source file:com.mobimvp.cliques.ui.BaseActivity.java

/**
 * Sets up the navigation drawer as appropriate. Note that the nav drawer will be
 * different depending on whether the attendee indicated that they are attending the
 * event on-site vs. attending remotely.
 *///from   w  w  w.ja v a 2s.c  o m
private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getSelfNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.theme_primary_dark));
    ScrimInsetsScrollView navDrawer = (ScrimInsetsScrollView) mDrawerLayout.findViewById(R.id.navdrawer);
    if (selfItem == NAVDRAWER_ITEM_INVALID) {
        // do not show a nav drawer
        if (navDrawer != null) {
            ((ViewGroup) navDrawer.getParent()).removeView(navDrawer);
        }
        mDrawerLayout = null;
        return;
    }

    if (navDrawer != null) {
        final View chosenAccountContentView = findViewById(R.id.chosen_account_content_view);
        final View chosenAccountView = findViewById(R.id.chosen_account_view);
        final int navDrawerChosenAccountHeight = getResources()
                .getDimensionPixelSize(R.dimen.navdrawer_chosen_account_height);
        navDrawer.setOnInsetsCallback(new ScrimInsetsScrollView.OnInsetsCallback() {
            @Override
            public void onInsetsChanged(Rect insets) {
                ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chosenAccountContentView
                        .getLayoutParams();
                lp.topMargin = insets.top;
                chosenAccountContentView.setLayoutParams(lp);

                ViewGroup.LayoutParams lp2 = chosenAccountView.getLayoutParams();
                lp2.height = navDrawerChosenAccountHeight + insets.top;
                chosenAccountView.setLayoutParams(lp2);
            }
        });
    }

    if (mActionBarToolbar != null) {
        mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer);
        mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawerLayout.openDrawer(Gravity.START);
            }
        });
    }

    mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            // run deferred action, if we have one
            if (mDeferredOnDrawerClosedRunnable != null) {
                mDeferredOnDrawerClosedRunnable.run();
                mDeferredOnDrawerClosedRunnable = null;
            }
            onNavDrawerStateChanged(false, false);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            onNavDrawerStateChanged(true, false);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            onNavDrawerSlide(slideOffset);
        }
    });

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);

    // populate the nav drawer with the correct items
    populateNavDrawer();

}

From source file:com.example.ray.firstapp.bottombar.BottomBar.java

private void updateItems(final BottomBarItemBase[] bottomBarItems) {
    if (mItemContainer == null) {
        initializeViews();/*ww  w .j av  a  2 s . c o  m*/
    }

    int index = 0;
    int biggestWidth = 0;

    mIsShiftingMode = MAX_FIXED_TAB_COUNT < bottomBarItems.length;

    if (!mIsDarkTheme && !mIgnoreNightMode && MiscUtils.isNightMode(mContext)) {
        mIsDarkTheme = true;
    }

    if (!mIsTabletMode && mIsShiftingMode) {
        mDefaultBackgroundColor = mCurrentBackgroundColor = mPrimaryColor;
        mBackgroundView.setBackgroundColor(mDefaultBackgroundColor);

        if (mContext instanceof Activity) {
            navBarMagic((Activity) mContext, this);
        }
    } else if (mIsDarkTheme) {
        darkThemeMagic();
    }

    View[] viewsToAdd = new View[bottomBarItems.length];

    for (BottomBarItemBase bottomBarItemBase : bottomBarItems) {
        int layoutResource;

        if (mIsShiftingMode && !mIsTabletMode) {
            layoutResource = R.layout.bb_bottom_bar_item_shifting;
        } else {
            layoutResource = mIsTabletMode ? R.layout.bb_bottom_bar_item_fixed_tablet
                    : R.layout.bb_bottom_bar_item_fixed;
        }

        View bottomBarTab = View.inflate(mContext, layoutResource, null);
        ImageView icon = (ImageView) bottomBarTab.findViewById(R.id.bb_bottom_bar_icon);

        icon.setImageDrawable(bottomBarItemBase.getIcon(mContext));

        if (!mIsTabletMode) {
            TextView title = (TextView) bottomBarTab.findViewById(R.id.bb_bottom_bar_title);
            title.setText(bottomBarItemBase.getTitle(mContext));

            if (mPendingTextAppearance != -1) {
                MiscUtils.setTextAppearance(title, mPendingTextAppearance);
            }

            if (mPendingTypeface != null) {
                title.setTypeface(mPendingTypeface);
            }
        }

        if (mIsDarkTheme || (!mIsTabletMode && mIsShiftingMode)) {
            icon.setColorFilter(mWhiteColor);
        }

        if (bottomBarItemBase instanceof BottomBarTab) {
            bottomBarTab.setId(((BottomBarTab) bottomBarItemBase).id);
        }

        if (index == mCurrentTabPosition) {
            selectTab(bottomBarTab, false);
        } else {
            unselectTab(bottomBarTab, false);
        }

        if (!mIsTabletMode) {
            if (bottomBarTab.getWidth() > biggestWidth) {
                biggestWidth = bottomBarTab.getWidth();
            }

            viewsToAdd[index] = bottomBarTab;
        } else {
            mItemContainer.addView(bottomBarTab);
        }

        bottomBarTab.setOnClickListener(this);
        bottomBarTab.setOnLongClickListener(this);
        index++;
    }

    if (!mIsTabletMode) {
        int proposedItemWidth = Math.min(MiscUtils.dpToPixel(mContext, mScreenWidth / bottomBarItems.length),
                mMaxFixedItemWidth);

        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(proposedItemWidth,
                LinearLayout.LayoutParams.WRAP_CONTENT);

        for (View bottomBarView : viewsToAdd) {
            bottomBarView.setLayoutParams(params);
            mItemContainer.addView(bottomBarView);
        }
    }

    if (mPendingTextAppearance != -1) {
        mPendingTextAppearance = -1;
    }

    if (mPendingTypeface != null) {
        mPendingTypeface = null;
    }
}

From source file:com.facebook.litho.ComponentHost.java

private void mountView(View view, int flags) {
    view.setDuplicateParentStateEnabled(MountItem.isDuplicateParentState(flags));

    mIsChildDrawingOrderDirty = true;/*from   w  w w. j a  v  a  2s.  co m*/

    // A host has been recycled and is already attached.
    if (view instanceof ComponentHost && view.getParent() == this) {
        finishTemporaryDetach(view);
        view.setVisibility(VISIBLE);
        return;
    }

    LayoutParams lp = view.getLayoutParams();
    if (lp == null) {
        lp = generateDefaultLayoutParams();
        view.setLayoutParams(lp);
    }

    if (mInLayout) {
        addViewInLayout(view, -1, view.getLayoutParams(), true);
    } else {
        addView(view, -1, view.getLayoutParams());
    }
}

From source file:br.liveo.ndrawer.ui.fragment.FragmentContactus.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub      
    View rootView = inflater.inflate(R.layout.fragment_contactus, container, false);

    TextView mTxtTitle = (TextView) rootView.findViewById(R.id.txtTitle1);
    //mTxtTitle.setText(getArguments().getString(TEXT_FRAGMENT));

    ivemaildtu = (ImageView) rootView.findViewById(R.id.ivemail_dtu);
    ivemailmukchaudhary = (ImageView) rootView.findViewById(R.id.ivemail_mukcha);
    ivemailmukkumar = (ImageView) rootView.findViewById(R.id.ivemail_mukkum);
    ivcallmukchaudhary = (ImageView) rootView.findViewById(R.id.ivcall_mukcha);
    ivcallmukkumar = (ImageView) rootView.findViewById(R.id.ivcall_mukkum);

    ivemaildtu.setOnClickListener(this);
    ivemailmukchaudhary.setOnClickListener(this);
    ivemailmukkumar.setOnClickListener(this);

    ivcallmukchaudhary.setOnClickListener(this);
    ivcallmukkumar.setOnClickListener(this);

    //  tvliveo1.setTypeface(EasyFonts.captureIt(getActivity()));
    //  tvliveo2.setTypeface(EasyFonts.captureIt(getActivity()));
    //  tvliveo3.setTypeface(EasyFonts.captureIt(getActivity()));
    //  tvliveo4.setTypeface(EasyFonts.captureIt(getActivity()));
    //  tvliveo5.setTypeface(EasyFonts.captureIt(getActivity()));
    //   tvliveo6.setTypeface(EasyFonts.captureIt(getActivity()));
    //  tvliveo7.setTypeface(EasyFonts.captureIt(getActivity()));

    rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    return rootView;

}

From source file:com.miz.functions.MizLib.java

public static void addNavigationBarMargin(Context c, View v) {
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);//from   ww w  .ja v  a2 s. com
    params.setMargins(0, 0, 0, getNavigationBarHeight(c));
    v.setLayoutParams(params);
}

From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java

void updateVolumeGroupItemHeight(View item) {
    LinearLayout container = (LinearLayout) item.findViewById(R.id.volume_item_container);
    setLayoutHeight(container, mVolumeGroupListItemHeight);
    View icon = item.findViewById(R.id.mr_volume_item_icon);
    ViewGroup.LayoutParams lp = icon.getLayoutParams();
    lp.width = mVolumeGroupListItemIconSize;
    lp.height = mVolumeGroupListItemIconSize;
    icon.setLayoutParams(lp);
}