当前位置: 首页>>代码示例>>Java>>正文


Java CardView.setLayoutParams方法代码示例

本文整理汇总了Java中android.support.v7.widget.CardView.setLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java CardView.setLayoutParams方法的具体用法?Java CardView.setLayoutParams怎么用?Java CardView.setLayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.CardView的用法示例。


在下文中一共展示了CardView.setLayoutParams方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SetNewContents

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void SetNewContents(int key) {
    if (!Changes(key).equals("null")) {
        CardView.LayoutParams param = new CardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        CardView card = new CardView(this);
        if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("DARK_THEME_KEY", false))
            card.setCardBackgroundColor(ContextCompat.getColor(this, R.color.DarkcolorPrimary));
        card.setCardElevation(5);
        card.setLayoutParams(param);
        card.setPadding(ConvertTopx(15), ConvertTopx(15), ConvertTopx(15), ConvertTopx(15));
        card.setUseCompatPadding(true);
        TextView changes = new TextView(this);
        changes.setGravity(Gravity.CENTER);
        changes.setPadding(ConvertTopx(5), ConvertTopx(5), ConvertTopx(5), ConvertTopx(5));
        changes.setText(Changes(key));
        changes.setTypeface(Typeface.MONOSPACE);
        if (firebaseRemoteConfig.getBoolean("mark_red") && key == 0)
            changes.setTextColor(Color.RED);
        card.addView(changes);
        layout.addView(card);
    }
    bar.setVisibility(View.GONE);
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:24,代码来源:ChangeLogActivity.java

示例2: ViewHolder

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
public ViewHolder(View itemView) {
    super(itemView);
    cardView = (CardView) itemView;
    cover = (FrameLayout) itemView.findViewById(R.id.cover_layout);
    imageButton = (ImageButton) itemView.findViewById(R.id.rank_image);
    categoryName = (TextView) itemView.findViewById(R.id.category_name);

    if (mActivity instanceof RecyclerViewActivity) {
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                TranslateDptoPiexel.translate(210, mActivity));
        cardView.setLayoutParams(params);
    }
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:14,代码来源:SquareCardBinder.java

示例3: initZoomRegionView

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
/**
 * Init the ZoomRegionView for navigate into image when user zoom in
 */
private void initZoomRegionView() {
    if (mZoomRegionView == null) {

        Bitmap init = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
        mContentBitmap = init.copy(Bitmap.Config.ARGB_8888, true);
        init.recycle();
        mContentCanvas = new Canvas(mContentBitmap);

        FrameLayout.LayoutParams layoutParams = new LayoutParams(getWidth() / 4, getHeight() / 4,
                Gravity.TOP | Gravity.END);
        layoutParams.setMargins(12, 12, 12, 12);
        mZoomRegionCardView = new CardView(getContext());
        mZoomRegionCardView.setLayoutParams(layoutParams);
        mZoomRegionCardView.setPreventCornerOverlap(true);
        mZoomRegionCardView.setRadius(0f);
        mZoomRegionCardView.setUseCompatPadding(true);
        mZoomRegionCardView.setVisibility(View.INVISIBLE);

        CardView.LayoutParams childLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        mZoomRegionView = new ZoomRegionView(getContext());
        mZoomRegionView.setLayoutParams(childLayoutParams);
        mZoomRegionView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        mZoomRegionView.setOnZoomRegionListener(new ZoomRegionView.OnZoomRegionListener() {
            @Override
            public void onZoomRegionMoved(Rect newRect) {
                mFromZoomRegion = true;
                mZoomCenterX = newRect.centerX() * 4;
                mZoomCenterY = newRect.centerY() * 4;

                invalidate();
            }
        });

        mZoomRegionCardView.addView(mZoomRegionView);
        addView(mZoomRegionCardView);
    }
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:42,代码来源:DrawView.java

示例4: updateSlideOffset

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void updateSlideOffset(View drawerView, float slideOffset) {
    final int absHorizGravity = getDrawerViewAbsoluteGravity(Gravity.START);
    final int childAbsGravity = getDrawerViewAbsoluteGravity(drawerView);


    for (int i = 0; i < frameLayout.getChildCount(); i++) {
        CardView child = (CardView) frameLayout.getChildAt(i);
        Setting setting = settings.get(childAbsGravity);
        float adjust = 0;

        if (setting != null) {

            child.setRadius((int) (setting.radius * slideOffset));
            super.setScrimColor(setting.scrimColor);
            super.setDrawerElevation(setting.drawerElevation);
            float percentage = 1f - setting.percentage;
            float reduceHeight = getHeight() * percentage * slideOffset;
            FrameLayout.LayoutParams params
                    = (FrameLayout.LayoutParams) child.getLayoutParams();
            params.topMargin = (int) (reduceHeight / 2);
            params.bottomMargin = (int) (reduceHeight / 2);
            child.setLayoutParams(params);
            child.setCardElevation(setting.elevation * slideOffset);
            adjust = setting.elevation;
            float width = childAbsGravity == absHorizGravity ?
                    drawerView.getWidth() + adjust : -drawerView.getWidth() - adjust;
            ViewCompat.setX(child, width * slideOffset);


        } else {
            super.setScrimColor(defaultScrimColor);
            super.setDrawerElevation(defaultDrawerElevation);
        }


    }

}
 
开发者ID:shiburagi,项目名称:Drawer-Behavior,代码行数:39,代码来源:AdvanceDrawerLayout.java

示例5: setAppointmentTexts

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void setAppointmentTexts()
{
    //Set the dynamic layout with appointment texts
    if(fireBaseMap!=null) {
        for (String s : appointmentTexts) {
            //Card view of the dynamic layout
            CardView cardView = new CardView(Appoinments.this);
            LinearLayout.LayoutParams lp = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    150));
            lp.setMargins(18, 20, 18, 20);
            cardView.setLayoutParams(lp);
            cardView.setCardBackgroundColor(0xff63D5C3);
            cardView.setPadding(30, 30, 30, 30);

            //Text view of the dynamic layout
            TextView textView = new TextView(Appoinments.this);
            LinearLayout.LayoutParams layoutParams = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.MATCH_PARENT));
            textView.setLayoutParams(layoutParams);
            textView.setGravity(Gravity.CENTER);
            textView.setText(s);
            textView.setTextColor(0xff000000); // hex color 0xAARRGGBB
            textView.setTextSize(16);
            textView.setTypeface(Typeface.create("monospace", Typeface.NORMAL));

            //Add the text view to card view
            cardView.addView(textView);


            //Add the card view to linear layout
            verticalLayout.addView(cardView);


        }

        //Set the number of appointments to a text view
        String numberOfAppointments = getString(R.string.appointment) + String.valueOf(listOfAppointments.size());
        appointmentTextView.setText(numberOfAppointments);
    }

}
 
开发者ID:Nihal369,项目名称:Amaro,代码行数:42,代码来源:Appoinments.java


注:本文中的android.support.v7.widget.CardView.setLayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。