Java Code Examples for android.support.v7.app.ActionBar.LayoutParams

The following are Jave code examples for showing how to use LayoutParams of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: head   File: HeadToolBar.java   Source Code and License Vote up 6 votes
/**
 * 设置右边图标靠右,解决靠右时与设置中间标题的冲突
 *
 * @param v
 */
private void addRightView(View v) {
    final ViewGroup.LayoutParams vlp = v.getLayoutParams();
    final LayoutParams lp;
    if (vlp == null) {
        lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.RIGHT;
    } else if (!checkLayoutParams(vlp)) {
        if (vlp instanceof LayoutParams) {
            lp = new LayoutParams((LayoutParams) vlp);
        } else if (vlp instanceof ActionBar.LayoutParams) {
            lp = new LayoutParams((ActionBar.LayoutParams) vlp);
        } else if (vlp instanceof MarginLayoutParams) {
            lp = new LayoutParams((MarginLayoutParams) vlp);
        } else {
            lp = new LayoutParams(vlp);
        }
        lp.gravity = Gravity.RIGHT;
    } else {
        lp = (LayoutParams) vlp;
    }
    addView(v, lp);
}
 
Example 2
Project: BAStatusBarLib   File: AddBarAftreKiK.java   Source Code and License Vote up 5 votes
/**
 * @return
 * @throws
 * @fuction 初始化并加载我们的状态栏背景,我们添加的这个背景,
 * 不是添加在Activit的布局中,而是Activity的contextFrameLayout中设置作为状态栏背景的View的属性
 * @parm
 */
@TargetApi(19)
@Override
public void addStatusBar() {
    if((request.isTrans()==request.isImageAsBg())) {
        Window window = request.getActivity().getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        ViewGroup.LayoutParams layoutParams =
                new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                        request.getStatusBarHeigth());
        addMyStatusView(layoutParams);
    }
}
 
Example 3
Project: TitleBar   File: TitleBar.java   Source Code and License Vote up 5 votes
/**
 * 创建{@link LayoutParams}
 * 用于指定添加到ToolBar的View的位置
 *
 * @param lp      view的LayoutParams
 * @param gravity CENTER,LEFT,RIGHT
 * @return LayoutParams
 */
private LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp, int gravity) {
    LayoutParams layoutParams;
    if (lp instanceof LayoutParams) {
        layoutParams = new LayoutParams((LayoutParams) lp);
    } else if (lp instanceof ActionBar.LayoutParams) {
        layoutParams = new LayoutParams((ActionBar.LayoutParams) lp);
    } else if (lp instanceof MarginLayoutParams) {
        layoutParams = new LayoutParams((MarginLayoutParams) lp);
    } else {
        layoutParams = new LayoutParams(lp);
    }
    layoutParams.gravity = gravity;
    return layoutParams;
}
 
Example 4
Project: head   File: HeadToolBar.java   Source Code and License Vote up 5 votes
@Override
protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
    LayoutParams lp;
    if (p instanceof LayoutParams) {
        lp = new LayoutParams((LayoutParams) p);
    } else if (p instanceof ActionBar.LayoutParams) {
        lp = new LayoutParams((ActionBar.LayoutParams) p);
    } else if (p instanceof MarginLayoutParams) {
        lp = new LayoutParams((MarginLayoutParams) p);
    } else {
        lp = new LayoutParams(p);
    }
    lp.gravity = Gravity.CENTER;
    return lp;
}
 
Example 5
Project: Mobike   File: MyToolBar.java   Source Code and License Vote up 5 votes
private void initview() {
        if (mView == null) {
            mInflater = LayoutInflater.from(getContext());
            mView = mInflater.inflate(R.layout.toolbar, null);
            mLRippleView = (RippleView) mView.findViewById(R.id.more);
            mRRippleView = (RippleView) mView.findViewById(R.id.more1);
            toolbar_rightButton = (ImageView) mView.findViewById(R.id.id_btn_right);
            toolbar_title = (TextView) mView.findViewById(R.id.id_tv_title);
            toolbar_searchview = (EditText) mView.findViewById(R.id.id_et_search);
            toolbar_leftButton = (ImageView) mView.findViewById(R.id.id_ib_navigation);
            ActionBar.LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            addView(mView, lp);
//            if (showSearchView) {
//                showSearchview();
//                hideTitle();
//            } else {
//                hideSearchview();
//                showTitle();
//                if (title != null) {
//                    toolbar_title.setText(title);
//                }
//            }
//            Log.d("left_button_icon", "initview:5"+left_button_icon);
//            if (left_button_icon != null) {
//
//                toolbar_leftButton.setBackground(left_button_icon);
//                toolbar_leftButton.setVisibility(VISIBLE);
//            }
//
//            if (right_button_icon != null) {
//                toolbar_rightButton.setImageDrawable(right_button_icon);
//                toolbar_rightButton.setVisibility(VISIBLE);
//            }

        }

    }
 
Example 6
Project: Viajes   File: MainActivity.java   Source Code and License Vote up 3 votes
@Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {


//            mSearchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_menu));
            mSearchView = new SearchView(getSupportActionBar().getThemedContext());
            ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT);
            mSearchView.setLayoutParams(params);
            mSearchView.setLayoutParams(new ActionBar.LayoutParams(Gravity.LEFT));
            mSearchView.setMaxWidth(Integer.MAX_VALUE);


//            mSearchView = new SearchView();


            setupSearchView(mSearchView);

            // search menu item
            MenuItem searchMenuItem = menu.add(Menu.NONE, Menu.NONE, 2, getString(R.string.menu_search));
            searchMenuItem.setIcon(R.drawable.search);
            searchMenuItem.expandActionView();
            MenuItemCompat.setActionView(searchMenuItem, mSearchView);
            MenuItemCompat.setShowAsAction(searchMenuItem, MenuItem.SHOW_AS_ACTION_ALWAYS);


            MenuItem searchMenuItem3 = menu.add(Menu.NONE, Menu.NONE, 1, getString(R.string.menu_search));
            searchMenuItem3.setIcon(R.drawable.search);
            MenuItemCompat.setActionView(searchMenuItem3, iv);
            MenuItemCompat.setShowAsAction(searchMenuItem3, MenuItem.SHOW_AS_ACTION_ALWAYS);


            return true;
        }