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


Java View.getBackground方法代码示例

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


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

示例1: viewIsOpaque

import android.view.View; //导入方法依赖的package包/类
private static boolean viewIsOpaque(View v) {
    if (v.isOpaque()) {
        return true;
    }

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18) {
        return false;
    }

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}
 
开发者ID:zhudongya123,项目名称:WechatChatroomHelper,代码行数:19,代码来源:BGASwipeBackLayout2.java

示例2: clipCanvasWithinBorderBox

import android.view.View; //导入方法依赖的package包/类
public static void clipCanvasWithinBorderBox(View targetView, Canvas canvas) {
  Drawable drawable;
  /* According to https://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported
    API 18 or higher supports clipPath to canvas based on hardware acceleration.
   */
  if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 ||
       !canvas.isHardwareAccelerated()) &&
      ((drawable = targetView.getBackground()) instanceof BorderDrawable)) {
    BorderDrawable borderDrawable = (BorderDrawable) drawable;
    if(borderDrawable.isRounded()) {
      Path path = borderDrawable.getContentPath(
          new RectF(0, 0, targetView.getWidth(), targetView.getHeight()));
      canvas.clipPath(path);
    }
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:17,代码来源:WXViewUtils.java

示例3: getBorderDrawable

import android.view.View; //导入方法依赖的package包/类
public static @Nullable
BorderDrawable getBorderDrawable(@NonNull View view){
  Drawable drawable=view.getBackground();
  if(drawable instanceof BorderDrawable){
    return (BorderDrawable) drawable;
  }
  else if(drawable instanceof LayerDrawable){
    if(((LayerDrawable) drawable).getNumberOfLayers()>1) {
      Drawable innerDrawable=((LayerDrawable) drawable).getDrawable(0);
      if(innerDrawable instanceof BorderDrawable){
        return (BorderDrawable) innerDrawable;
      }
    }
  }
  return null;
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:17,代码来源:WXViewUtils.java

示例4: SmartViewHolder

import android.view.View; //导入方法依赖的package包/类
public SmartViewHolder(View itemView, AdapterView.OnItemClickListener mListener) {
    super(itemView);
    this.mListener = mListener;
    itemView.setOnClickListener(this);

    /**
     * 设置水波纹背景
     */
    if (itemView.getBackground() == null) {
        TypedValue typedValue = new TypedValue();
        Resources.Theme theme = itemView.getContext().getTheme();
        int top = itemView.getPaddingTop();
        int bottom = itemView.getPaddingBottom();
        int left = itemView.getPaddingLeft();
        int right = itemView.getPaddingRight();
        if (theme.resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true)) {
            itemView.setBackgroundResource(typedValue.resourceId);
        }
        itemView.setPadding(left, top, right, bottom);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:SmartViewHolder.java

示例5: setClickedItem

import android.view.View; //导入方法依赖的package包/类
private void setClickedItem(View view, NodeInfo item) {
    mClickedNodeInfo = item;
    if (mClickedView == null) {
        mOriginalBackground = view.getBackground();
    } else {
        mClickedView.setBackground(mOriginalBackground);
    }
    view.setBackgroundColor(mClickedColor);
    mClickedView = view;
    invalidate();
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:12,代码来源:LayoutHierarchyView.java

示例6: adaptAddTabButtonColor

import android.view.View; //导入方法依赖的package包/类
/**
 * Adapts the color of a button, which allows to add a new tab.
 *
 * @param addTabItem
 *         The add tab item, which corresponds to the button, whose color should be adapted, as
 *         an instance of the class {@link AddTabItem}. The add tab item may not be null
 */
private void adaptAddTabButtonColor(@NonNull final AddTabItem addTabItem) {
    ColorStateList colorStateList = getStyle().getAddTabButtonColor();
    int[] stateSet = new int[]{};
    int color = colorStateList.getColorForState(stateSet, colorStateList.getDefaultColor());
    View view = addTabItem.getView();
    Drawable background = view.getBackground();
    background.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:16,代码来源:TabletTabRecyclerAdapter.java

示例7: fixBackgroundRepeat

import android.view.View; //导入方法依赖的package包/类
public static void fixBackgroundRepeat(View view) {
    Drawable bg = view.getBackground();
    if (bg != null) {
        if (bg instanceof BitmapDrawable) {
            BitmapDrawable bmp = (BitmapDrawable) bg;
            bmp.mutate(); // make sure that we aren't sharing state anymore
            bmp.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        }
    }
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:11,代码来源:Util.java

示例8: get

import android.view.View; //导入方法依赖的package包/类
@Override
public Integer get(View object) {
  int color;
  BorderDrawable borderDrawable;
  if ((borderDrawable = WXViewUtils.getBorderDrawable(object)) != null) {
    color = borderDrawable.getColor();
  } else if (object.getBackground() instanceof ColorDrawable) {
    color = ((ColorDrawable) object.getBackground()).getColor();
  } else {
    color = Color.TRANSPARENT;
    WXLogUtils.e(TAG, "Unsupported background type");
  }
  return color;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:15,代码来源:BackgroundColorProperty.java

示例9: view2Bitmap

import android.view.View; //导入方法依赖的package包/类
/**
 * view转bitmap
 *
 * @param view 视图
 * @return bitmap
 */
public static Bitmap view2Bitmap(final View view) {
    if (view == null) return null;
    Bitmap ret = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(ret);
    Drawable bgDrawable = view.getBackground();
    if (bgDrawable != null) {
        bgDrawable.draw(canvas);
    } else {
        canvas.drawColor(Color.WHITE);
    }
    view.draw(canvas);
    return ret;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ImageUtils.java

示例10: hasOpaqueBackground

import android.view.View; //导入方法依赖的package包/类
private static boolean hasOpaqueBackground(View v) {
    Drawable bg = v.getBackground();
    if (bg == null || bg.getOpacity() != -1) {
        return false;
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:DrawerLayout.java

示例11: setPressViewHotSpot

import android.view.View; //导入方法依赖的package包/类
private void setPressViewHotSpot(final MotionEvent e, final View mPressedView) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        /**
         * when   click   Outside the region  ,mPressedView is null
         */
        if (mPressedView != null && mPressedView.getBackground() != null) {
            mPressedView.getBackground().setHotspot(e.getRawX(), e.getY() - mPressedView.getY());
        }
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:11,代码来源:SimpleClickListener.java

示例12: inflate

import android.view.View; //导入方法依赖的package包/类
@Override
public View inflate(LayoutInflater inflater) {
    View view = inflater.inflate(R.layout.nim_contacts_select_item, null);
    defaultBackground = view.getBackground();
    this.image = (HeadImageView) view.findViewById(R.id.img_head);
    this.nickname = (TextView) view.findViewById(R.id.tv_nickname);
    this.select = (ImageView) view.findViewById(R.id.imgSelect);
    return view;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:10,代码来源:ContactsSelectHolder.java

示例13: createAnimator

import android.view.View; //导入方法依赖的package包/类
private static @Nullable
ObjectAnimator createAnimator(@NonNull WXAnimationBean animation, final View target) {
  if(target == null){
    return null;
  }
  WXAnimationBean.Style style = animation.styles;
  if (style != null) {
    ObjectAnimator animator;
    List<PropertyValuesHolder> holders =style.getHolders();
    if (!TextUtils.isEmpty(style.backgroundColor)) {
      BorderDrawable borderDrawable;
      if ((borderDrawable=WXViewUtils.getBorderDrawable(target))!=null) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            borderDrawable.getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      } else if (target.getBackground() instanceof ColorDrawable) {
        holders.add(PropertyValuesHolder.ofObject(
            WXAnimationBean.Style.BACKGROUND_COLOR, new ArgbEvaluator(),
            ((ColorDrawable) target.getBackground()).getColor(),
            WXResourceUtils.getColor(style.backgroundColor)));
      }
    }
    if (style.getPivot() != null) {
      Pair<Float, Float> pair = style.getPivot();
      target.setPivotX(pair.first);
      target.setPivotY(pair.second);
    }
    animator = ObjectAnimator.ofPropertyValuesHolder(
        target, holders.toArray(new PropertyValuesHolder[holders.size()]));
    animator.setStartDelay(animation.delay);
    final IntEvaluator intEvaluator=new IntEvaluator();
    if (target.getLayoutParams() != null &&
        (!TextUtils.isEmpty(style.width) || !TextUtils.isEmpty(style.height))) {
      DimensionUpdateListener listener = new DimensionUpdateListener(target);
      ViewGroup.LayoutParams layoutParams = target.getLayoutParams();
      if (!TextUtils.isEmpty(style.width)) {
        listener.setWidth(layoutParams.width,
                          (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.width)));
      }
      if (!TextUtils.isEmpty(style.height)) {
        listener.setHeight(layoutParams.height,
                           (int) WXViewUtils.getRealPxByWidth(WXUtils.getFloat(style.height)));
      }
      animator.addUpdateListener(listener);
    }
    return animator;
  } else {
    return null;
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:52,代码来源:WXAnimationModule.java

示例14: viewIsOpaque

import android.view.View; //导入方法依赖的package包/类
private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v)) return true;

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18) return false;

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}
 
开发者ID:chemickypes,项目名称:Glitchy,代码行数:15,代码来源:SideMenu.java

示例15: onChangedTextColor

import android.view.View; //导入方法依赖的package包/类
public void onChangedTextColor(View view) {
    Drawable background = view.getBackground();
    ColorDrawable colorDrawable = (ColorDrawable) background;

    switch (curSelect) {
        case SELECT_TEXTS:
            if (null != curCellInfo) {
                curCellInfo.textColor = colorDrawable.getColor();
                table.updateData(curCellInfo);
            } else if (null != curMergeInfo) {
                curMergeInfo.textColor = colorDrawable.getColor();
                table.updateMergeData(curMergeInfo);
            }
            break;
        case SELECT_BG:
            if (null != curCellInfo) {
                curCellInfo.bgColor = colorDrawable.getColor();
                table.updateData(curCellInfo);
            } else if (null != curMergeInfo) {
                curMergeInfo.bgColor = colorDrawable.getColor();
                table.updateMergeData(curMergeInfo);
            }
            break;
        case SELECT_STROKE:
            table.setStrokeColor(colorDrawable.getColor());
            table.reset();
            break;
        case SELECT_OUT_STROKE:
            table.setOutStrokeColor(colorDrawable.getColor());
            table.reset();
            break;
    }
}
 
开发者ID:huzenan,项目名称:EasyTableView,代码行数:34,代码来源:MainActivity.java


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