android.view.ViewGroup.MarginLayoutParams#MATCH_PARENT源码实例Demo

下面列出了android.view.ViewGroup.MarginLayoutParams#MATCH_PARENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android   文件: BaseActivity.java
@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);
}
 
源代码2 项目: delion   文件: BookmarkPage.java
/**
 * 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);
}