Java Code Examples for android.view.ViewGroup.MarginLayoutParams#MATCH_PARENT

The following examples show how to use android.view.ViewGroup.MarginLayoutParams#MATCH_PARENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseActivity.java    From android with MIT License 6 votes vote down vote up
@Override
public void setContentView(@LayoutRes int layoutResID) {
    viewRootLayout = (CoordinatorLayout) findViewById(R.id.viewRootLayout);
    View content = LayoutInflater.from(this).inflate(layoutResID, null);

    int marginLayoutParams = MarginLayoutParams.MATCH_PARENT;
    MarginLayoutParams params = new MarginLayoutParams(marginLayoutParams, marginLayoutParams);
    params.topMargin = Utils.getActionBarHeight();
    viewRootLayout.addView(content, params);

    viewToolbar = (Toolbar) findViewById(R.id.viewToolbar);
    if (viewToolbar != null) {
        setSupportActionBar(viewToolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true); // 设置返回按钮可见
        getSupportActionBar().setDisplayShowHomeEnabled(true); // 设置是否显示logo图标
        getSupportActionBar().setHomeButtonEnabled(true); // 设置左上角的图标可点击
    }

    ButterKnife.bind(this);
}
 
Example 2
Source File: BookmarkPage.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new instance of the bookmarks page.
 * @param activity The activity to get context and manage fragments.
 * @param tab The tab to load urls.
 */
public BookmarkPage(Activity activity, Tab tab) {
    mActivity = activity;
    mTab = tab;
    mTitle = activity.getString(R.string.bookmarks);
    mBackgroundColor = ApiCompatibilityUtils.getColor(activity.getResources(),
            R.color.default_primary_color);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);

    mManager = new BookmarkManager(mActivity, false);
    Resources res = mActivity.getResources();

    MarginLayoutParams layoutParams = new MarginLayoutParams(
            MarginLayoutParams.MATCH_PARENT, MarginLayoutParams.MATCH_PARENT);
    layoutParams.setMargins(0,
            res.getDimensionPixelSize(R.dimen.tab_strip_height)
            + res.getDimensionPixelSize(R.dimen.toolbar_height_no_shadow),
            0, 0);
    mManager.getView().setLayoutParams(layoutParams);
    mManager.setUrlChangeListener(this);
}