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


Java CardView.getChildAt方法代码示例

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


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

示例1: onActionClick

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
protected void onActionClick(View action) {
    super.onActionClick(action);
    CardView cardView = (CardView) action;
    RelativeLayout relativeLayout = (RelativeLayout) cardView.getChildAt(0);
    ImageView imageView = (ImageView) relativeLayout.getChildAt(0);
    switch ((int) imageView.getTag()) {
        case R.drawable.ic_call:
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" +
                    event.getContact1().split(":")[1]));
            startActivity(intent);
            break;

        case R.drawable.ic_map:
            startActivity(new Intent(EventDetailActivity.this, MapsActivity.class)
                    .putExtra("location", event.getLocation()));
            break;
    }
}
 
开发者ID:adithya321,项目名称:Instincts-2k17,代码行数:20,代码来源:EventDetailActivity.java

示例2: onUpdateViewAlpha

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
protected void onUpdateViewAlpha(@NonNull View view, float alpha) {
    final CardView card = ((CardView)view);
    final View alphaView = card.getChildAt(1);
    final View imageView = card.getChildAt(0);

    final boolean isLeftCard = alpha < 1;
    if (isLeftCard) {
        ViewCompat.setAlpha(alphaView, 0.9f - alpha);
        ViewCompat.setAlpha(imageView, 0.3f + alpha);
    } else {
        if (ViewCompat.getAlpha(alphaView) != 0) {
            ViewCompat.setAlpha(alphaView, 0f);
        }

        if (ViewCompat.getAlpha(imageView) != 1) {
            ViewCompat.setAlpha(imageView, 1f);
        }
    }
}
 
开发者ID:Ramotion,项目名称:showroom-android,代码行数:21,代码来源:CardsUpdater.java

示例3: onClick

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void onClick(View view) {
    final CardSliderLayoutManager lm =  (CardSliderLayoutManager) recyclerView.getLayoutManager();

    if (lm.isSmoothScrolling()) {
        return;
    }

    final int activeCardPosition = lm.getActiveCardPosition();
    if (activeCardPosition == RecyclerView.NO_POSITION) {
        return;
    }

    final int clickedPosition = recyclerView.getChildAdapterPosition(view);
    if (clickedPosition == activeCardPosition) {
        final Intent intent = new Intent(MainActivity.this, DetailsActivity.class);
        intent.putExtra(DetailsActivity.BUNDLE_IMAGE_ID, pics[activeCardPosition % pics.length]);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            startActivity(intent);
        } else {
            final CardView cardView = (CardView) view;
            final View sharedView = cardView.getChildAt(cardView.getChildCount() - 1);
            final ActivityOptions options = ActivityOptions
                    .makeSceneTransitionAnimation(MainActivity.this, sharedView, "shared");
            startActivity(intent, options.toBundle());
        }
    } else if (clickedPosition > activeCardPosition) {
        recyclerView.smoothScrollToPosition(clickedPosition);
        onActiveCardChange(clickedPosition);
    }
}
 
开发者ID:Ramotion,项目名称:cardslider-android,代码行数:33,代码来源:MainActivity.java

示例4: updateView

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void updateView(@NonNull View view, float position) {
    super.updateView(view, position);

    final CardView card = ((CardView)view);
    final View alphaView = card.getChildAt(1);
    final View imageView = card.getChildAt(0);

    if (position < 0) {
        final float alpha = ViewCompat.getAlpha(view);
        ViewCompat.setAlpha(view, 1f);
        ViewCompat.setAlpha(alphaView, 0.9f - alpha);
        ViewCompat.setAlpha(imageView, 0.3f + alpha);
    } else {
        ViewCompat.setAlpha(alphaView, 0f);
        ViewCompat.setAlpha(imageView, 1f);
    }

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        final CardSliderLayoutManager lm =  getLayoutManager();
        final float ratio = (float) lm.getDecoratedLeft(view) / lm.getActiveCardLeft();

        final float z;

        if (position < 0) {
            z = Z_CENTER_1 * ratio;
        } else if (position < 0.5f) {
            z = Z_CENTER_1;
        } else if (position < 1f) {
            z = Z_CENTER_2;
        } else {
            z = Z_RIGHT;
        }

        card.setCardElevation(Math.max(0, z));
    }
}
 
开发者ID:Ramotion,项目名称:cardslider-android,代码行数:38,代码来源:CardsUpdater.java

示例5: getView

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@NonNull
public View getView() {
    Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) mSnackBar.getView();

    boolean tabletMode = mBuilder.mContext.getResources().getBoolean(R.bool.cafebar_tablet_mode);

    if (tabletMode || mBuilder.mFloating) {
        CardView cardView = (CardView) snackBarLayout.getChildAt(0);
        return cardView.getChildAt(0);
    }

    LinearLayout linearLayout = (LinearLayout) snackBarLayout.getChildAt(0);
    if (mBuilder.mShowShadow) return linearLayout.getChildAt(1);
    return linearLayout.getChildAt(0);
}
 
开发者ID:danimahardhika,项目名称:cafebar,代码行数:16,代码来源:CafeBar.java

示例6: onBindViewHolder

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) {

    Model model = items.get(position);
    if (model == null) {
        return;
    }
    RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    RecyclerView.LayoutParams lp2 = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    switch (model.getType()) {
        case Model.TEXT_TYPE:
        case Model.COMMENT_TYPE:
            TextView textView = (TextView) model.getTheContent();
            ((ViewHolderText) holder).text.setText(textView.getText());
            ((ViewHolderText) holder).text.setPadding(textView.getPaddingLeft(), textView.getPaddingTop(), textView.getPaddingRight(), textView.getPaddingBottom());
            ((ViewHolderText) holder).text.setTypeface(textView.getTypeface());
            ((ViewHolderText) holder).text.setTextColor(textView.getCurrentTextColor());
            if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                ((ViewHolderText) holder).text.setBackground(textView.getBackground());
            }
            if (textView.getBackground() != null) {
                ((ViewHolderText) holder).text.setAllCaps(true);
            }
            // Tag doesn't expand horizontally to the max
            if (textView.getLayoutParams() != null) {
                ((ViewHolderText) holder).text.setLayoutParams(textView.getLayoutParams());
            } else {
                ((ViewHolderText) holder).text.setLayoutParams(lp);
            }
            ((ViewHolderText) holder).text.setTextSize(TypedValue.COMPLEX_UNIT_PX, textView.getTextSize());
            break;
        case Model.IMAGE_TYPE:
            String imageURI = (String) model.getTheContent();
            ((ViewHolderImage) holder).image.setLayoutParams(lp);
            Picasso.with(((ViewHolderImage) holder).image.getContext()).load(imageURI).into(((ViewHolderImage) holder).image);
            break;
        case Model.TWEET_TYPE:
            CardView cardView = (CardView) model.getTheContent();
            TextView tweet = (TextView) cardView.getChildAt(0);
            Button link = (Button) cardView.getChildAt(1);
            ((ViewHolderTweet) holder).getTweet().setText(tweet.getText());
            ((ViewHolderTweet) holder).getLink().setContentDescription(link.getContentDescription());
            break;
        case Model.GRAPH_TYPE_BARS:
            Chart chart1 = (Chart) model.getTheContent();
            ((ViewHolderChart) holder).chart.setData(chart1.getData());
            ((ViewHolderChart) holder).chart.setLayoutParams(lp2);
            break;
        case Model.GRAPH_TYPE_COLUMNS:
            Chart chart2 = (Chart) model.getTheContent();
            ((ViewHolderChart) holder).chart.setData(chart2.getData());
            ((ViewHolderChart) holder).chart.setLayoutParams(lp2);
            break;
    }
}
 
开发者ID:MBach,项目名称:LeMondeRssReader,代码行数:57,代码来源:ArticleAdapter.java


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