android.support.v7.widget.CardView#setUseCompatPadding ( )源码实例Demo

下面列出了android.support.v7.widget.CardView#setUseCompatPadding ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: KakaoBot   文件: SettingPopup.java
private void init() {
    LinearLayout frame = new LinearLayout(context);
    CardView card = new CardView(context);

    card.setUseCompatPadding(true);
    card.setContentPadding(MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8));
    card.setCardElevation(12.f);

    card.addView(layout);
    frame.addView(card);

    this.setContentView(frame);
    this.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    this.setFocusable(true);
    this.setBackgroundDrawable(new BitmapDrawable());
    this.setOutsideTouchable(true);
}
 
源代码2 项目: candybar-library   文件: AboutAdapter.java
ContributorsViewHolder(View itemView) {
    super(itemView);
    TextView title = itemView.findViewById(R.id.title);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_people, color), null, null, null);
    title.setText(mContext.getResources().getString(R.string.about_contributors_title));

    title.setOnClickListener(this);
}
 
源代码3 项目: candybar-library   文件: HomeAdapter.java
ContentViewHolder(View itemView) {
    super(itemView);
    container = itemView.findViewById(R.id.container);
    autoFitTitle = itemView.findViewById(R.id.title);
    subtitle = itemView.findViewById(R.id.subtitle);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    container.setOnClickListener(this);
}
 
源代码4 项目: candybar-library   文件: HomeAdapter.java
IconRequestViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    installedApps = itemView.findViewById(R.id.installed_apps);
    missedApps = itemView.findViewById(R.id.missed_apps);
    themedApps = itemView.findViewById(R.id.themed_apps);
    progress = itemView.findViewById(R.id.progress);
    container = itemView.findViewById(R.id.container);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_icon_request, color), null, null, null);

    int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);

    container.setOnClickListener(this);
}
 
源代码5 项目: candybar-library   文件: HomeAdapter.java
WallpapersViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    TextView muzei = itemView.findViewById(R.id.muzei);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_wallpapers, color), null, null, null);

    muzei.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.get(
            mContext, R.drawable.ic_home_app_muzei), null, null, null);

    title.setOnClickListener(this);
    muzei.setOnClickListener(this);
}
 
源代码6 项目: candybar-library   文件: HomeAdapter.java
GooglePlayDevViewHolder(View itemView) {
    super(itemView);
    container = itemView.findViewById(R.id.container);
    title = itemView.findViewById(R.id.title);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_google_play_more_apps, color), null, null, null);

    container.setOnClickListener(this);
}
 
源代码7 项目: candybar-library   文件: RequestAdapter.java
ContentViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.name);
    content = itemView.findViewById(R.id.requested);
    icon = itemView.findViewById(R.id.icon);
    checkbox = itemView.findViewById(R.id.checkbox);
    container = itemView.findViewById(R.id.container);
    divider = itemView.findViewById(R.id.divider);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    container.setOnClickListener(this);
    container.setOnLongClickListener(this);
}
 
源代码8 项目: candybar-library   文件: LauncherAdapter.java
ViewHolder(View itemView, int viewType) {
    super(itemView);
    if (viewType == TYPE_HEADER) {
        name = itemView.findViewById(R.id.name);
        holderId = TYPE_HEADER;
    } else if (viewType == TYPE_CONTENT) {
        icon = itemView.findViewById(R.id.icon);
        name = itemView.findViewById(R.id.name);
        container = itemView.findViewById(R.id.container);

        CardView card = itemView.findViewById(R.id.card);
        if (CandyBarApplication.getConfiguration().getApplyGrid() == CandyBarApplication.GridStyle.FLAT) {
            if (card.getLayoutParams() instanceof GridLayoutManager.LayoutParams) {
                card.setRadius(0f);
                card.setUseCompatPadding(false);
                int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
                GridLayoutManager.LayoutParams params = (GridLayoutManager.LayoutParams) card.getLayoutParams();
                params.setMargins(0, 0, margin, margin);

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    params.setMarginEnd(margin);
                }
            }
        }
        if (!Preferences.get(mContext).isCardShadowEnabled()) {
            if (card != null) card.setCardElevation(0);
        }

        holderId = TYPE_CONTENT;

        container.setOnClickListener(this);
    }
}
 
源代码9 项目: candybar-library   文件: AboutAdapter.java
FooterViewHolder(View itemView) {
    super(itemView);
    ImageView instagram = itemView.findViewById(R.id.about_dev_instagram);
    ImageView googlePlus = itemView.findViewById(R.id.about_dev_google_plus);
    ImageView github = itemView.findViewById(R.id.about_dev_github);
    TextView title = itemView.findViewById(R.id.about_dashboard_title);
    TextView licenses = itemView.findViewById(R.id.about_dashboard_licenses);
    TextView contributors = itemView.findViewById(R.id.about_dashboard_contributors);
    TextView translator = itemView.findViewById(R.id.about_dashboard_translator);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getAboutStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        if (card != null) card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_dashboard, color), null, null, null);

    color = ConfigurationHelper.getSocialIconColor(mContext,
            CandyBarApplication.getConfiguration().getSocialIconColor());
    instagram.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_instagram, color));
    googlePlus.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_google_plus, color));
    github.setImageDrawable(DrawableHelper.getTintedDrawable(mContext, R.drawable.ic_toolbar_github, color));

    instagram.setOnClickListener(this);
    googlePlus.setOnClickListener(this);
    github.setOnClickListener(this);
    licenses.setOnClickListener(this);
    contributors.setOnClickListener(this);
    translator.setOnClickListener(this);
}
 
源代码10 项目: candybar-library   文件: RequestAdapter.java
HeaderViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    content = itemView.findViewById(R.id.content);
    button = itemView.findViewById(R.id.buy);

    container = itemView.findViewById(R.id.premium_request);
    total = itemView.findViewById(R.id.premium_request_total);
    available = itemView.findViewById(R.id.premium_request_available);
    used = itemView.findViewById(R.id.premium_request_used);
    progress = itemView.findViewById(R.id.progress);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getRequestStyle() == CandyBarApplication.Style.PORTRAIT_FLAT_LANDSCAPE_FLAT &&
            card != null) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled() && card != null) {
        card.setCardElevation(0);
    }

    int padding = mContext.getResources().getDimensionPixelSize(R.dimen.content_margin) +
            mContext.getResources().getDimensionPixelSize(R.dimen.icon_size_small);
    content.setPadding(padding, 0, 0, 0);
    container.setPadding(padding, 0, padding, 0);

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(
            DrawableHelper.getTintedDrawable(mContext,
                    R.drawable.ic_toolbar_premium_request, color),
            null, null, null);

    int primary = ColorHelper.getAttributeColor(mContext, R.attr.colorPrimary);
    int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    button.setTextColor(ColorHelper.getTitleTextColor(primary));

    progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);

    button.setOnClickListener(this);
}