本文整理汇总了Java中android.view.View.setLayerType方法的典型用法代码示例。如果您正苦于以下问题:Java View.setLayerType方法的具体用法?Java View.setLayerType怎么用?Java View.setLayerType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.setLayerType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addView
import android.view.View; //导入方法依赖的package包/类
void addView(final int position) {
View root = createView(position, mParent);
root.setOnTouchListener(this);
root.setTag(R.id.cardstack_internal_position_tag, position);
root.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mCardPaddingInternal = root.getPaddingTop();
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, fullCardHeight);
root.setLayoutParams(lp);
if (mShowInitAnimation) {
root.setY(getCardFinalY(position));
setScreenTouchable(false);
} else {
root.setY(getCardOriginalY(position) - mParentPaddingTop);
setScreenTouchable(true);
}
mCardViews[position] = root;
mParent.addView(root);
}
示例2: greyItem
import android.view.View; //导入方法依赖的package包/类
/**
* 变化Item的灰度值
* @param child 需要设置灰度值的Item
* @param frame 位置信息
*/
private void greyItem(View child, Rect frame) {
float value = computeGreyScale(frame.left - mOffsetAll);
ColorMatrix cm = new ColorMatrix(new float[]{
value, 0, 0, 0, 120*(1-value),
0, value, 0, 0, 120*(1-value),
0, 0, value, 0, 120*(1-value),
0, 0, 0, 1, 250*(1-value),
});
// cm.setSaturation(0.9f);
// Create a paint object with color matrix
Paint greyPaint = new Paint();
greyPaint.setColorFilter(new ColorMatrixColorFilter(cm));
// Create a hardware layer with the grey paint
child.setLayerType(View.LAYER_TYPE_HARDWARE, greyPaint);
if (value >= 1) {
// Remove the hardware layer
child.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
示例3: disableHardwareLayer
import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void disableHardwareLayer() {
if (!API_11) return;
View v;
for (int i = 0; i < getChildCount(); i++) {
v = getChildAt(i);
if (v.getLayerType() != View.LAYER_TYPE_NONE)
v.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
示例4: setGreyscale
import android.view.View; //导入方法依赖的package包/类
/**
* 设置View的灰度
*/
public static void setGreyscale(View v, boolean greyscale) {
if (greyscale) {
// Create a paint object with 0 saturation (black and white)
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
Paint greyscalePaint = new Paint();
greyscalePaint.setColorFilter(new ColorMatrixColorFilter(cm));
// Create a hardware layer with the greyscale paint
v.setLayerType(LAYER_TYPE_HARDWARE, greyscalePaint);
} else {
// Remove the hardware layer
v.setLayerType(LAYER_TYPE_NONE, null);
}
}
示例5: addNextView
import android.view.View; //导入方法依赖的package包/类
private void addNextView() {
if (adapterIndex < mAdapter.getCount()) {
View newBottomChild = mAdapter.getView(adapterIndex, null, this);
newBottomChild.setLayerType(View.LAYER_TYPE_HARDWARE, null);
//todo: i'm setting the card to invisible initially and making it visible when i animate
//later
newBottomChild.setAlpha(0);
newBottomChild.setY(getPaddingTop());
final long viewId = mAdapter.getItemId(adapterIndex);
CardContainer card = new CardContainer(newBottomChild, this, new CardContainerCallback(viewId));
card.setPositionWithinAdapter(adapterIndex);
if (leftImageResource != 0) {
card.setLeftImageResource(leftImageResource);
}
if (rightImageResource != 0) {
card.setRightImageResource(rightImageResource);
}
card.setId(viewId);
deck.addBack(card);
adapterIndex++;
}
}
示例6: manageLayer
import android.view.View; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void manageLayer(View v, boolean enableHardware) {
if (!API_11) return;
int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
if (layerType != v.getLayerType())
v.setLayerType(layerType, null);
}
示例7: manageLayer
import android.view.View; //导入方法依赖的package包/类
@TargetApi(11)
private void manageLayer(View v, boolean enableHardware) {
if (API_11) {
int layerType = enableHardware ? 2 : 0;
if (layerType != v.getLayerType()) {
v.setLayerType(layerType, null);
}
}
}
示例8: disableHardwareLayer
import android.view.View; //导入方法依赖的package包/类
@TargetApi(11)
private void disableHardwareLayer() {
if (API_11) {
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
if (v.getLayerType() != 0) {
v.setLayerType(0, null);
}
}
}
}
示例9: setSepiaLayer
import android.view.View; //导入方法依赖的package包/类
private void setSepiaLayer (View view, boolean isSepiaLayerOn) {
if (!IS_JBMR2) {
if (isSepiaLayerOn) {
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
view.setLayerPaint(mSepiaPaint);
} else {
view.setLayerPaint(mDefaultPaint);
}
}
}
示例10: setLayerType
import android.view.View; //导入方法依赖的package包/类
@TargetApi(11)
public static void setLayerType(View view, int layerType, Paint paint) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
view.setLayerType(layerType, paint);
}
}
示例11: setLayerType
import android.view.View; //导入方法依赖的package包/类
public static void setLayerType(View view, int layerType) {
view.setLayerType(layerType, null);
}
示例12: setLayerType
import android.view.View; //导入方法依赖的package包/类
public static void setLayerType(View view, int layerType, Paint paint) {
view.setLayerType(layerType, paint);
}
示例13: setLayerType
import android.view.View; //导入方法依赖的package包/类
public static void setLayerType(View view, int layerType) {
view.setLayerType(layerType, null);
}
示例14: bindPost
import android.view.View; //导入方法依赖的package包/类
private void bindPost(PostViewHolder viewHolder, Post post) {
viewHolder.title.setText(post.getTitle());
if (! TextUtils.isEmpty(post.getFeatureImage())) {
String imageUrl = NetworkUtils.makeAbsoluteUrl(mBlogUrl, post.getFeatureImage());
viewHolder.image.setVisibility(View.VISIBLE);
mPicasso.load(imageUrl)
.fit().centerCrop()
.into(viewHolder.image);
} else {
viewHolder.image.setVisibility(View.GONE);
viewHolder.image.setImageResource(android.R.color.transparent);
}
@ColorInt int postStatusColor = PostUtils.getStatusColor(post, mContext);
viewHolder.statusIcon.setImageResource(PostUtils.getStatusIconResId(post));
viewHolder.statusIcon.setColorFilter(postStatusColor, PorterDuff.Mode.SRC_IN);
viewHolder.statusText.setText(PostUtils.getStatusString(post, mContext));
viewHolder.statusText.setTextColor(postStatusColor);
List<Tag> tags = post.getTags();
if (tags.size() > 0) {
String tagsStr = "#" + tags.get(0).getName();
if (tags.size() > 1) {
tagsStr += " +" + (tags.size()-1);
}
viewHolder.tags.setText(tagsStr);
viewHolder.tags.setVisibility(View.VISIBLE);
} else {
viewHolder.tags.setVisibility(View.GONE);
}
// grey out to-be-deleted posts, by making all the child Views of the item translucent
ViewGroup viewGroup = (ViewGroup) viewHolder.itemView;
boolean isMarkedForDeletion = post.isMarkedForDeletion();
for (int i = 0, len = viewGroup.getChildCount(); i < len; ++i) {
View childView = viewGroup.getChildAt(i);
if (isMarkedForDeletion) {
childView.setLayerType(View.LAYER_TYPE_HARDWARE, mLowAlphaPaint);
} else {
childView.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
}
示例15: setHoldView
import android.view.View; //导入方法依赖的package包/类
final public void setHoldView(View v) {
mViewCache.setHoldView(v);
if (softwareRender()) {
v.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}