コード例 #1
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   final int mPosition = position;
   Semester semester = (Semester) mData.get(mPosition).get("semester");
   convertView = super.getView(position, convertView, parent);
   final ImageView img = (ImageView) convertView.findViewById(R.id.select);
   if (localSemesterId == semester.id) {
     img.setImageResource(R.drawable.check);
     img.setPadding(
         img.getPaddingLeft(),
         img.getPaddingTop(),
         img.getPaddingRight() + ImageHlp.changeToSystemUnitFromDP(convertView.getContext(), 3),
         img.getPaddingBottom());
   }
   return convertView;
 }
コード例 #2
0
  /**
   * 为view设置一个折叠的角
   *
   * @param v
   */
  public void setViewTucked(Context context, View v) {
    Drawable d = v.getBackground();
    int w = v.getLayoutParams().width;
    int h = v.getLayoutParams().height;
    int tuck = (int) ImageHlp.changeToSystemUnitFromDP(context, 15);
    Bitmap bt = Bitmap.createBitmap(w, h, Config.ARGB_8888);
    Path path = new Path();
    path.moveTo(0, 0);
    path.lineTo(w - tuck, 0);
    path.lineTo(w, tuck);
    path.lineTo(w, h);
    path.lineTo(0, h);
    path.lineTo(0, 0);
    Canvas mCanvas = new Canvas(bt);
    mCanvas.clipPath(path);
    d.setBounds(0, 0, w, h);
    d.draw(mCanvas);

    Path wPath = new Path();
    wPath.moveTo(w - tuck, 0);
    wPath.lineTo(w - tuck, tuck);
    wPath.lineTo(w, tuck);
    wPath.lineTo(w - tuck, 0);
    mCanvas.clipPath(wPath);
    mCanvas.drawARGB(64, 255, 255, 255);

    Canvas mCanvas1 = new Canvas(bt);
    Path bPath = new Path();
    bPath.moveTo(w - tuck, tuck);
    bPath.lineTo(w, tuck);
    bPath.lineTo(w, tuck * 2);
    bPath.lineTo(w - tuck, tuck);
    mCanvas1.clipPath(bPath);
    mCanvas1.drawARGB(39, 0, 0, 0);

    BitmapDrawable bd = new BitmapDrawable(v.getContext().getResources(), bt);
    Compatibility.setBackground(v, bd);
  }
コード例 #3
0
 public int getSizeFromStyleFile(int fileSize) {
   return ImageHlp.changeToSystemUnitFromDP(App.getInstance(), fileSize / 2);
 }