Java Code Examples for android.support.v7.widget.CardView#setLayoutParams()
The following examples show how to use
android.support.v7.widget.CardView#setLayoutParams() .
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: ColorizeFaceActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
public MultipleColorHolder(View itemView) { super(itemView); mView = itemView; makeup_product_color_card = (CardView) itemView.findViewById(R.id.makeup_product_color_card); makeup_product_color_card.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); select_color_layout = (LinearLayout) itemView.findViewById(R.id.select_color_layout); makeup_product_color_image[0] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image1); makeup_product_color_image[1] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image2); makeup_product_color_image[2] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image3); makeup_product_color_image[3] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image4); makeup_product_color_image[4] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image5); makeup_product_color_image[5] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image6); makeup_product_color_image[6] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image7); makeup_product_color_image[7] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image8); }
Example 2
Source File: SingleMakeupActivity.java From FaceT with Mozilla Public License 2.0 | 6 votes |
public MultipleColorHolder(View itemView) { super(itemView); mView = itemView; makeup_product_color_card = (CardView) itemView.findViewById(R.id.makeup_product_color_card); makeup_product_color_card.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); select_color_layout = (LinearLayout) itemView.findViewById(R.id.select_color_layout); makeup_product_color_image[0] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image1); makeup_product_color_image[1] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image2); makeup_product_color_image[2] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image3); makeup_product_color_image[3] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image4); makeup_product_color_image[4] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image5); makeup_product_color_image[5] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image6); makeup_product_color_image[6] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image7); makeup_product_color_image[7] = (CircleImageView) itemView.findViewById(R.id.makeup_product_color_image8); }
Example 3
Source File: AlohaActivity.java From YImagePicker with Apache License 2.0 | 5 votes |
/** * 设置简单图片适配器 * * @param imageItems 图片信息列表 */ public void setImageViewList(@Nullable List<? extends ImageItem> imageItems) { if (imageItems == null) { return; } if (viewList == null) { viewList = new ArrayList<>(); } else { viewList.clear(); } ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); for (final ImageItem entity : imageItems) { CardView cardView = new CardView(this); cardView.setCardElevation(dp(2)); cardView.setRadius(dp(5)); cardView.setLayoutParams(params); CropImageView imageView = new CropImageView(this); imageView.setLayoutParams(params); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); if (entity.getCropUrl() != null && entity.getCropUrl().length() > 0) { Glide.with(this).load(entity.getCropUrl()).into(imageView); } else { Glide.with(this).load(entity.path).into(imageView); } cardView.addView(imageView); viewList.add(cardView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { intentCrop(entity); } }); } setViewList(viewList); }
Example 4
Source File: ViewHelper.java From FABRevealMenu-master with Apache License 2.0 | 5 votes |
public CardView generateBaseView() { //Base view CardView mBaseView = new CardView(mContext); mBaseView.setLayoutParams(matchParams); mBaseView.setCardElevation(dpToPx(mContext, 5)); mBaseView.setRadius(mContext.getResources().getDimension(R.dimen.card_radius)); return mBaseView; }
Example 5
Source File: MainActivity.java From BmapLite with GNU General Public License v3.0 | 4 votes |
@Override protected void initView(int layoutID) { super.initView(layoutID); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); textSearch = getView(R.id.text_search); mTextPoiName = getView(R.id.text_poi_name); mTextPoiDistance = getView(R.id.text_poi_distance); mTextCollection = getView(R.id.text_collection); mTextStreet = getView(R.id.text_street); mTextNearby = getView(R.id.text_nearby); mTextDetails = getView(R.id.text_details); mTextShare = getView(R.id.text_share); mRecycleResult = getView(R.id.recycler_result); mLayPoi = getView(R.id.lay_poi); mLaySearchResult = getView(R.id.lay_search_result); btnLine = getView(R.id.fab_line); //mBtnRoute = getView(R.id.fab_route); //btnLine.setOnClickListener(this); textSearch.setOnClickListener(this); LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecycleResult.setLayoutManager(layoutManager); mRecycleResult.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); mDrawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = getView(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); mMenuRanging = navigationView.getMenu().findItem(R.id.nav_ranging); if (BApp.TYPE_MAP == TypeMap.TYPE_AMAP) { navigationView.getMenu().findItem(R.id.nav_change_map).setTitle("切换百度地图"); } else if (BApp.TYPE_MAP == TypeMap.TYPE_BAIDU) { navigationView.getMenu().findItem(R.id.nav_change_map).setTitle("切换高德地图"); } int statusHeight = StatusBarUtils.getStatusBarHeight(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { StatusBarUtils.setStatusBarColor(this, Color.TRANSPARENT); CardView cardView = getView(R.id.card_view); CoordinatorLayout.LayoutParams layoutParams2 = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AppUtils.dip2Px(this, 45)); layoutParams2.topMargin = statusHeight + AppUtils.dip2Px(this, 10); layoutParams2.rightMargin = AppUtils.dip2Px(this, 10); layoutParams2.leftMargin = AppUtils.dip2Px(this, 10); layoutParams2.bottomMargin = AppUtils.dip2Px(this, 10); cardView.setLayoutParams(layoutParams2); FrameLayout layStatus = getView(R.id.lay_status); layStatus.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusHeight)); layStatus.setVisibility(View.VISIBLE); } initMap(); showPoiLay(null, -1); }
Example 6
Source File: MainActivity.java From BmapLite with Apache License 2.0 | 4 votes |
@Override protected void initView(int layoutID) { super.initView(layoutID); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(""); setSupportActionBar(toolbar); textSearch = getView(R.id.text_search); mTextPoiName = getView(R.id.text_poi_name); mTextPoiDistance = getView(R.id.text_poi_distance); mTextCollection = getView(R.id.text_collection); mTextStreet = getView(R.id.text_street); mTextNearby = getView(R.id.text_nearby); mTextDetails = getView(R.id.text_details); mTextShare = getView(R.id.text_share); mRecycleResult = getView(R.id.recycler_result); mLayPoi = getView(R.id.lay_poi); mLaySearchResult = getView(R.id.lay_search_result); btnLine = getView(R.id.fab_line); //mBtnRoute = getView(R.id.fab_route); //btnLine.setOnClickListener(this); textSearch.setOnClickListener(this); LinearLayoutManager layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecycleResult.setLayoutManager(layoutManager); mRecycleResult.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); mDrawer.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = getView(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); mMenuRanging = navigationView.getMenu().findItem(R.id.nav_ranging); if (BApp.TYPE_MAP == TypeMap.TYPE_AMAP) { navigationView.getMenu().findItem(R.id.nav_change_map).setTitle("切换百度地图"); } else if (BApp.TYPE_MAP == TypeMap.TYPE_BAIDU) { navigationView.getMenu().findItem(R.id.nav_change_map).setTitle("切换高德地图"); } int statusHeight = StatusBarUtils.getStatusBarHeight(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { StatusBarUtils.setStatusBarColor(this, Color.TRANSPARENT); CardView cardView = getView(R.id.card_view); CoordinatorLayout.LayoutParams layoutParams2 = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, AppUtils.dip2Px(this, 45)); layoutParams2.topMargin = statusHeight + AppUtils.dip2Px(this, 10); layoutParams2.rightMargin = AppUtils.dip2Px(this, 10); layoutParams2.leftMargin = AppUtils.dip2Px(this, 10); layoutParams2.bottomMargin = AppUtils.dip2Px(this, 10); cardView.setLayoutParams(layoutParams2); FrameLayout layStatus = getView(R.id.lay_status); layStatus.setLayoutParams(new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, statusHeight)); layStatus.setVisibility(View.VISIBLE); } initMap(); showPoiLay(null, -1); }
Example 7
Source File: CardsFragment.java From iGap-Android with GNU Affero General Public License v3.0 | 4 votes |
private void addEmptyCard() { Context context = getContext(); int dp8 = RaadCommonUtils.getPx(8, context); int dp16 = RaadCommonUtils.getPx(16, context); int cardHeight = BankCardView.getDefaultCardHeight(getContext()); CardView cardView = new CardView(context); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, cardHeight); params.setMargins(dp16, 0, dp16, dp16); cardView.setLayoutParams(params); if (WalletActivity.isDarkTheme) { cardView.setCardBackgroundColor(Color.parseColor(WalletActivity.backgroundTheme_2)); } else { cardView.setCardBackgroundColor(Color.parseColor(WalletActivity.backgroundTheme)); } cardView.setPreventCornerOverlap(false); cardView.setCardElevation(RaadCommonUtils.getPx(6, context)); cardView.setRadius(RaadCommonUtils.getPx(8, context)); cardsLayout.addView(cardView); viewItems.add(cardView); TextView textView = new TextView(context); CardView.LayoutParams textViewParams = new CardView.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); textViewParams.gravity = Gravity.CENTER; textView.setLayoutParams(textViewParams); textView.setGravity(Gravity.CENTER); textView.setTextColor(Color.parseColor(WalletActivity.textTitleTheme)); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); textView.setTypeface(Typefaces.get(context, Typefaces.IRAN_YEKAN_REGULAR)); textView.setText(R.string.click_here_for_adding_card); cardView.addView(textView); cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ((NavigationBarActivity) getActivity()).pushFullFragment( new AddCardFragment(), "AddCardFragment"); } }); }
Example 8
Source File: PopMenuView.java From PopMenuLayout with MIT License | 4 votes |
private void init(Context context){ mMenus = new ArrayList<MenuBean>(); mMenuAdapter = new MenuAdapter(mContext, mMenus, mLayoutManagerOrientation); mMenuAdapter.setMenuWidth(mWidth); mMenuAdapter.setTextPaddingLeft(mMenuTextPaddingLeft); mMenuAdapter.setTextPaddingBottom(mMenuTextPaddingBottom); mMenuAdapter.setTextPaddingRight(mMenuTextPaddingRight); mMenuAdapter.setTextPaddingTop(mMenuTextPaddingTop); mMenuAdapter.setDividerDp(mMenuDividerDp); mMenuAdapter.setDividerColor(mDividerColor); mMenuAdapter.setExpandableIcon(mExpandableIcon); mMenuAdapter.setMenuTextColor(mMenuTextColor); mMenuAdapter.setHorizontalMenuBackgroundRes(mHorizontalMenuBackgroundRes); mMenuAdapter.setVerticalMenuBackgroundRes(mVerticalMenuBackgroundRes); mMenuAdapter.setMenuTextSize(mMenuTextSize); mMenuAdapter.setOnMenuClickListener(new OnMenuClickListener() { @Override public void onMenuClick(int level1Index, int level2Index, int level3Index) { dealMenuClickEvent(level1Index, level2Index, level3Index); } }); mLayoutManager = new LinearLayoutManager(mContext); mLayoutManager.setOrientation(mLayoutManagerOrientation); mRootView = LayoutInflater.from(mContext).inflate(R.layout.view_menu_container, null); mCardView = (CardView) mRootView.findViewById(R.id.cardView); mCardView.setCardBackgroundColor(mMenuLayoutBgColor); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mCardView.getLayoutParams(); if (mWidth != -1){ params.width = mWidth; } if (mHeight != -1){ params.height = mHeight; } mCardView.setLayoutParams(params); mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerView); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setAdapter(mMenuAdapter); setContentView(mRootView); setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); setFocusable(true); setAnimationStyle(mAnimStyle); setBackgroundDrawable(new ColorDrawable(0x00000000)); }
Example 9
Source File: ListFragment1.java From visual-goodies with Apache License 2.0 | 4 votes |
private void addHeaderView(){ //Lets add a header view CardBuilder cardBuilder = new CardBuilder(CardBuilder.CardType.FULL_WIDTH_IMAGE); cardBuilder.setTitle("This is an header view!") .setSubTitle("The cards are still in early development") .setText("some text goes \n\nhere!") .useLightTheme(false) .setPrimaryAction(new View.OnClickListener() { @Override public void onClick(View v) { MessageDialog.show(getActivity(), "You tapped the card", null); } }) .addSupplementalAction(new CardBuilder.CardAction("Action1", 1)) .addActionClickListener(new CardBuilder.CardActionClickListener() { @Override public void onCardActionClicked(CardBuilder.CardAction action) { Toast.makeText(getActivity(), "Action pressed!", Toast.LENGTH_SHORT).show(); } }) .setImage(BitmapFactory.decodeResource(getResources(), R.drawable.lisbon)); //We want the card to have some padding so let's add it to a linear layout (not mandatory) // LinearLayout linear = new LinearLayout(getActivity()); // linear.setLayoutParams( // new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, // ViewGroup.LayoutParams.WRAP_CONTENT)); int sixteenDPasPX = ViewUtils.convertDPtoPixels(getActivity(), 16); //This build the card and adds it to the linear layout CardView cardView = cardBuilder.build(getActivity()); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(sixteenDPasPX, sixteenDPasPX, sixteenDPasPX, (int) (sixteenDPasPX * 1.5)); cardView.setLayoutParams(layoutParams); cardView.setCardBackgroundColor(Color.parseColor("#FF5722")); //Finally, we add the view to the adapter mListAdapter.addHeaderView(cardView); }
Example 10
Source File: CanDialog.java From CanDialog with Apache License 2.0 | 3 votes |
/** * 设置加载的dialog * * @param loadText String */ public void setProgress(String loadText) { setType(DIALOG_PROGRESS); View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_progress, null); TextView tv_load = (TextView) view.findViewById(R.id.tv_load); tv_load.setText(loadText); showListOrEditView(view); hideButtons(); hideTitle(); CardView cardView = (CardView) findViewById(R.id.card); FrameLayout.LayoutParams params = (LayoutParams) cardView.getLayoutParams(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; params.height = ViewGroup.LayoutParams.WRAP_CONTENT; params.gravity = Gravity.CENTER; cardView.setRadius(InputUtils.dp2px(getContext(),3)); cardView.setLayoutParams(params); setFullBackgroundColor(Color.TRANSPARENT); }