private void updatelayoutIconVideo() {
    // update for video ion big
    LayoutParams lpImageBox;
    if (mImage != null) {
      lpImageBox = (LayoutParams) mImage.getLayoutParams();
    } else {
      lpImageBox = (LayoutParams) mLLTitle.getLayoutParams();
    }

    int width = lpImageBox.width;
    int height = lpImageBox.height;

    FrameLayout.LayoutParams lpLLTitle = (LayoutParams) mLLTitle.getLayoutParams();

    int heightPortion = height - lpLLTitle.height;

    if (heightPortion == 0) {
      height = getBoxSupposeHeight();
      heightPortion = height - lpLLTitle.height;
    }

    FrameLayout.LayoutParams lpVideoIcon = (LayoutParams) mIvVideoIconBig.getLayoutParams();

    if (lpLLTitle.height > height / 2) {
      lpVideoIcon.gravity = Gravity.CENTER_VERTICAL;
      lpVideoIcon.leftMargin = width / 2 - lpVideoIcon.width / 2;
    }

    if (Math.abs(heightPortion) > height / 3) {
      lpVideoIcon.gravity = Gravity.CENTER_HORIZONTAL;
      lpVideoIcon.topMargin = heightPortion / 2 - lpVideoIcon.height / 2;
    }
    mIvVideoIconBig.setLayoutParams(lpVideoIcon);
    mIvVideoIconBig.setVisibility(VISIBLE);
  }
  private void toggleCamera(boolean isNeedEnableCam) {

    // TODO temporary insertion will be removed when GLVideoView will be fixed
    DisplayMetrics displaymetrics = new DisplayMetrics();
    displaymetrics.setToDefaults();

    ViewGroup.LayoutParams layoutParams = imgMyCameraOff.getLayoutParams();

    layoutParams.height = localVideoView.getHeight();
    layoutParams.width = localVideoView.getWidth();

    imgMyCameraOff.setLayoutParams(layoutParams);

    Log.d(
        TAG,
        "Width is: "
            + imgMyCameraOff.getLayoutParams().width
            + " height is:"
            + imgMyCameraOff.getLayoutParams().height);

    if (SessionManager.getCurrentSession() != null) {
      SessionManager.getCurrentSession().setVideoEnabled(isNeedEnableCam);
      cameraToggle.setChecked(isNeedEnableCam);

      if (isNeedEnableCam) {
        Log.d(TAG, "Camera is on");
        switchCameraToggle.setVisibility(View.VISIBLE);
        imgMyCameraOff.setVisibility(View.INVISIBLE);
      } else {
        Log.d(TAG, "Camera is off");
        switchCameraToggle.setVisibility(View.INVISIBLE);
        imgMyCameraOff.setVisibility(View.VISIBLE);
      }
    }
  }
  private void transformImageBitmap(ImageView child, Transformation t, int rotationAngle) {
    // 对效果进行保存
    mCamera.save();
    final Matrix imageMatrix = t.getMatrix();
    // 图片高度
    final int imageHeight = child.getLayoutParams().height;
    // 图片宽度
    final int imageWidth = child.getLayoutParams().width;

    // 返回旋转角度的绝对值
    final int rotation = Math.abs(rotationAngle);

    // 在Z轴上正向移动camera的视角,实际效果为放大图片。
    // 如果在Y轴上移动,则图片上下移动;X轴上对应图片左右移动。
    mCamera.translate(0.0f, 0.0f, 100.0f);
    // As the angle of the view gets less, zoom in
    if (rotation < mMaxRotationAngle) {
      float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
      mCamera.translate(0.0f, 0.0f, zoomAmount);
    }
    // 在Y轴上旋转,对应图片竖向向里翻转。
    // 如果在X轴上旋转,则对应图片横向向里翻转。
    mCamera.rotateY(rotationAngle);
    mCamera.getMatrix(imageMatrix);
    imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
    imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
    mCamera.restore();
  }
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    this.innerView.measure(widthMeasureSpec, heightMeasureSpec);
    ImageView iv1 = (ImageView) this.innerView.findViewById(R.id.top_item_1);
    LayoutParams lp = iv1.getLayoutParams();
    lp.height = iv1.getMeasuredWidth();
    iv1.setLayoutParams(lp);

    ImageView iv2 = (ImageView) this.innerView.findViewById(R.id.top_item_2);
    lp = iv2.getLayoutParams();
    lp.height = iv2.getMeasuredWidth();
    iv2.setLayoutParams(lp);

    ImageView iv3 = (ImageView) this.innerView.findViewById(R.id.top_item_3);
    lp = iv3.getLayoutParams();
    lp.height = iv3.getMeasuredWidth();
    iv3.setLayoutParams(lp);

    TextView tv = (TextView) this.innerView.findViewById(R.id.top_item_others);
    lp = tv.getLayoutParams();
    lp.height = iv3.getMeasuredWidth();
    tv.setLayoutParams(lp);

    this.innerView.measure(widthMeasureSpec, heightMeasureSpec);

    this.setMeasuredDimension(
        this.innerView.getMeasuredWidth(), this.innerView.getMeasuredHeight());
  }
  private void setLinePositions(GridLayoutView glv) {

    // extend imgageView to bounds
    Bitmap bitmapy = BitmapFactory.decodeResource(getResources(), R.drawable.line_y);
    bitmapy = Bitmap.createScaledBitmap(bitmapy, glWidth, bitmapy.getHeight(), true);
    lineY.setImageBitmap(bitmapy);

    Bitmap bitmapx = BitmapFactory.decodeResource(getResources(), R.drawable.line_x);
    bitmapx = Bitmap.createScaledBitmap(bitmapx, bitmapx.getWidth(), glHeight, true);
    lineX.setImageBitmap(bitmapx);

    xParams = (RelativeLayout.LayoutParams) lineX.getLayoutParams();
    yParams = (RelativeLayout.LayoutParams) lineY.getLayoutParams();

    int positionLineXCentre = glv.getAxisXlines().get(glv.getGridSize() / 2).x;
    xParams.leftMargin =
        shapeStartPointX(glv.getZeroPosX(), glv.getLineSpacingX(), lineStartCoordX)
            - bitmapx.getWidth() / 2;
    lineX.setLayoutParams(xParams);

    int positionLineYCentre = glv.getAxisYlines().get(glv.getGridSize() / 2).y;
    yParams.topMargin =
        shapeStartPointY(glv.getZeroPosY(), glv.getLineSpacingY(), lineStartCoordY)
            - bitmapy.getHeight() / 2;
    lineY.setLayoutParams(yParams);
  }
Esempio n. 6
0
  private void moveToolbar(boolean moveTop) {
    if (toolbarOnTop == moveTop) {
      return;
    }
    toolbarOnTop = moveTop;
    if (toolbarOnTop) {
      offsetDueToToolBarPosition = toolbarHeight;
    } else {
      offsetDueToToolBarPosition = 0;
    }

    RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) zoomedImageView.getLayoutParams();
    RelativeLayout.LayoutParams pChangeZoomFactorButton =
        (RelativeLayout.LayoutParams) changeZoomFactorButton.getLayoutParams();
    RelativeLayout.LayoutParams pCloseButton =
        (RelativeLayout.LayoutParams) closeButton.getLayoutParams();

    if (moveTop) {
      p.addRule(RelativeLayout.BELOW, R.id.change_zoom_factor);
      pChangeZoomFactorButton.addRule(RelativeLayout.BELOW, 0);
      pCloseButton.addRule(RelativeLayout.BELOW, 0);
    } else {
      p.addRule(RelativeLayout.BELOW, 0);
      pChangeZoomFactorButton.addRule(RelativeLayout.BELOW, R.id.zoomed_image_view);
      pCloseButton.addRule(RelativeLayout.BELOW, R.id.zoomed_image_view);
    }
    pChangeZoomFactorButton.addRule(RelativeLayout.ALIGN_LEFT, R.id.zoomed_image_view);
    pCloseButton.addRule(RelativeLayout.ALIGN_RIGHT, R.id.zoomed_image_view);
    zoomedImageView.setLayoutParams(p);
    changeZoomFactorButton.setLayoutParams(pChangeZoomFactorButton);
    closeButton.setLayoutParams(pCloseButton);
  }
  @Override
  public void onDragEnd() {
    // TODO Auto-generated method stub

    MyAbsoluteLayout.LayoutParams startHandleParams =
        (MyAbsoluteLayout.LayoutParams) mStartSelectionHandle.getLayoutParams();
    MyAbsoluteLayout.LayoutParams endHandleParams =
        (MyAbsoluteLayout.LayoutParams) mEndSelectionHandle.getLayoutParams();

    float scale = getDensityIndependentValue(getScale(), mContext);

    float startX = startHandleParams.x - getScrollX();
    float startY = startHandleParams.y - getScrollY();
    float endX = endHandleParams.x - getScrollX();
    float endY = endHandleParams.y - getScrollY();

    startX = getDensityIndependentValue(startX, mContext) / scale;
    startY = getDensityIndependentValue(startY, mContext) / scale;
    endX = getDensityIndependentValue(endX, mContext) / scale;
    endY = getDensityIndependentValue(endY, mContext) / scale;

    if (mLastTouchedSelectionHandle == SELECTION_START_HANDLE && startX > 0 && startY > 0) {
      String saveStartString =
          String.format("javascript: android.selection.setStartPos(%f, %f);", startX, startY);
      loadUrl(saveStartString);
    }

    if (mLastTouchedSelectionHandle == SELECTION_END_HANDLE && endX > 0 && endY > 0) {
      String saveEndString =
          String.format("javascript: android.selection.setEndPos(%f, %f);", endX, endY);
      loadUrl(saveEndString);
    }

    mDragging = false;
  }
        public void handleMessage(Message m) {

          MyAbsoluteLayout.LayoutParams startParams =
              (MyAbsoluteLayout.LayoutParams) mStartSelectionHandle.getLayoutParams();
          startParams.x =
              (int)
                  (mSelectionBounds.left - mStartSelectionHandle.getDrawable().getIntrinsicWidth());
          startParams.y =
              (int)
                  (mSelectionBounds.top - mStartSelectionHandle.getDrawable().getIntrinsicHeight());

          // Stay on screen.
          startParams.x = (startParams.x < 0) ? 0 : startParams.x;
          startParams.y = (startParams.y < 0) ? 0 : startParams.y;

          mStartSelectionHandle.setLayoutParams(startParams);

          MyAbsoluteLayout.LayoutParams endParams =
              (MyAbsoluteLayout.LayoutParams) mEndSelectionHandle.getLayoutParams();
          endParams.x = (int) mSelectionBounds.right;
          endParams.y = (int) mSelectionBounds.bottom;

          // Stay on screen
          endParams.x = (endParams.x < 0) ? 0 : endParams.x;
          endParams.y = (endParams.y < 0) ? 0 : endParams.y;

          mEndSelectionHandle.setLayoutParams(endParams);
        }
Esempio n. 9
0
  private void transformImageBitmap(ImageView child, Transformation trans, int rotationAngle) {
    mCamera.save();

    final Matrix imageMatrix = trans.getMatrix();
    final int imageHeight = child.getLayoutParams().height;
    final int imageWidth = child.getLayoutParams().width;
    final int rotation = Math.abs(rotationAngle);

    // 在Z轴上正向移动camera的视角,实际效果为放大图片; 如果在Y轴上移动,则图片上下移动; X轴上对应图片左右移动。
    mCamera.translate(0.0f, 0.0f, -20.0f);

    // As the angle of the view gets less, zoom in
    if (rotation < mMaxRotationAngle) {
      float zoomAmount = (float) (mMaxZoom + (rotation * 1.0));
      mCamera.translate(0.0f, 0.0f, zoomAmount);
    }

    mCamera.rotateY(rotationAngle); // rotationAngle 为正,沿y轴向内旋转; 为负,沿y轴向外旋转

    mCamera.getMatrix(imageMatrix);
    imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
    imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));

    mCamera.restore();
  }
Esempio n. 10
0
 private void resizeLogo() {
   Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
   Point screenSize = new Point(); // used to store screen size
   display.getSize(screenSize); // store size in screenSize
   iv_logo.getLayoutParams().height = (int) (screenSize.y * 0.25);
   img_background.getLayoutParams().height = (int) (screenSize.y * 0.33);
   iv_logo.getLayoutParams().width = (int) (screenSize.y * 0.25);
 }
 private void bindDrawableResources() {
   mBitmapCache = new SparseArray<Bitmap>();
   ImageView openMrsLogoImage = (ImageView) findViewById(R.id.openmrsLogo);
   createImageBitmap(R.drawable.openmrs_logo, openMrsLogoImage.getLayoutParams());
   ImageView urlEdit = (ImageView) findViewById(R.id.urlEdit);
   createImageBitmap(R.drawable.ico_edit, urlEdit.getLayoutParams());
   openMrsLogoImage.setImageBitmap(mBitmapCache.get(R.drawable.openmrs_logo));
   urlEdit.setImageBitmap(mBitmapCache.get(R.drawable.ico_edit));
 }
  private void setPic() {

    Log.d("setPic", "Display image " + mCurrentPhotoPath);

    ImageView imageView = (ImageView) findViewById(R.id.cameraImage);

    int targetW = imageView.getWidth();
    int targetH = imageView.getHeight();

    Log.d("setPic", "layout ( " + targetW + " * " + targetH + " )");

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    Log.d("setPic", "display ( " + width + " * " + height + " )");

    imageView.getLayoutParams().width = ((width / 100) * 80);
    ;
    imageView.getLayoutParams().height = ((height / 100) * 80);
    imageView.requestLayout();

    targetW = imageView.getWidth();
    targetH = imageView.getHeight();

    Log.d("setPic", "new layout ( " + targetW + " * " + targetH + " )");

    /*
    // working for local image
            Bitmap bmp;
            bmp=BitmapFactory.decodeResource(getResources(),R.drawable.miau);//image is your image
            bmp=Bitmap.createScaledBitmap(bmp, targetW,targetH, true);
            imageView.setImageBitmap(bmp);
    */

    // Get the dimensions of the bitmap
    BitmapFactory.Options bmOptions = new BitmapFactory.Options();
    bmOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
    int photoW = bmOptions.outWidth;
    int photoH = bmOptions.outHeight;

    Log.d("setPic", "photo ( " + photoW + " * " + photoH + " )");

    // Determine how much to scale down the image
    int scaleFactor = Math.min(photoW / targetW, photoH / targetH);

    // Decode the image file into a Bitmap sized to fill the View
    bmOptions.inJustDecodeBounds = false;
    bmOptions.inSampleSize = scaleFactor;
    bmOptions.inPurgeable = true;

    Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);
    imageView.setImageBitmap(bitmap);
  }
 /**
  * 해당 ImageView 의 크기를 임의로 조정하는 method <br>
  * Resize ImageView by what you want.
  *
  * @param iv - ImageView variable
  * @param width - set width of ImageView
  * @param height - set height of ImageView
  */
 public static void resizeImageView(ImageView iv, int width, int height) {
   //        iv.setLayoutParams(new ViewGroup.LayoutParams(width, height));
   iv.requestLayout();
   if (width != 0) {
     iv.getLayoutParams().width = width;
   }
   if (height != 0) {
     iv.getLayoutParams().height = height;
   }
 }
Esempio n. 14
0
  private void setHeaderHeight(ImageView header) {
    int width;
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    width = size.x;

    if (isInLandscape()) header.getLayoutParams().width = width / 4;
    else header.getLayoutParams().width = width / 3;
  }
 public void load(ImageView imageView, String url, Drawable errorImage) {
   load(
       imageView,
       url,
       0,
       imageView.getLayoutParams().width > 0 ? imageView.getLayoutParams().width : DEFAULT_WIDTH,
       imageView.getLayoutParams().height > 0
           ? imageView.getLayoutParams().height
           : DEFAULT_HEIGHT,
       false,
       errorImage);
 }
 public void load(ImageView imageView, String url, int defaultBackround) {
   load(
       imageView,
       url,
       defaultBackround,
       imageView.getLayoutParams().width > 0 ? imageView.getLayoutParams().width : DEFAULT_WIDTH,
       imageView.getLayoutParams().height > 0
           ? imageView.getLayoutParams().height
           : DEFAULT_HEIGHT,
       false,
       null);
 }
 public void load(ImageView imageView, String url, boolean isCache) {
   load(
       imageView,
       url,
       0,
       imageView.getLayoutParams().width > 0 ? imageView.getLayoutParams().width : DEFAULT_WIDTH,
       imageView.getLayoutParams().height > 0
           ? imageView.getLayoutParams().height
           : DEFAULT_HEIGHT,
       isCache,
       null);
 }
Esempio n. 18
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   ImageView imageView = (ImageView) findViewById(R.id.imageview);
   imageView.setLayoutParams(new LinearLayout.LayoutParams(200, 100));
   setTitle(
       "height:"
           + imageView.getLayoutParams().width
           + "  height:"
           + imageView.getLayoutParams().height);
 }
 public void load(
     ImageView imageView, String url, int defaultBackround, boolean isCache, Drawable errorImage) {
   load(
       imageView,
       url,
       defaultBackround,
       imageView.getLayoutParams().width > 0 ? imageView.getLayoutParams().width : DEFAULT_WIDTH,
       imageView.getLayoutParams().height > 0
           ? imageView.getLayoutParams().height
           : DEFAULT_HEIGHT,
       isCache,
       errorImage);
 }
Esempio n. 20
0
  /**
   * Transform the Image Bitmap by the Angle passed
   *
   * @param imageView ImageView the ImageView whose bitmap we want to rotate
   * @param t transformation
   * @param rotationAngle the Angle by which to rotate the Bitmap
   */
  private void transformImageBitmap(ImageView child, Transformation t, float angle, float deltaY) {
    mCamera.save();
    final Matrix imageMatrix = t.getMatrix();
    final int imageHeight = child.getLayoutParams().height;
    final int imageWidth = child.getLayoutParams().width;

    mCamera.translate(0.0f, -(float) deltaY, 0.0f);
    mCamera.rotateZ(angle);
    mCamera.getMatrix(imageMatrix);
    imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
    imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
    mCamera.restore();
  }
Esempio n. 21
0
  @Override
  public void onStateChange(View view, HideablePartBehavior.State state) {
    switch (state) {
      case COLLAPSED:
        if (collapsed) return;
        if (getView() == null) return;
        collapsed = true;
        ((RelativeLayout.LayoutParams) send.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            R.id.text;
        ((RelativeLayout.LayoutParams) target.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            0;
        ((RelativeLayout.LayoutParams) text.getLayoutParams()).getRules()[RelativeLayout.LEFT_OF] =
            R.id.send;

        ((CoordinatorLayout.LayoutParams) commentFrame.getLayoutParams()).rightMargin =
            (int) (getView().getResources().getDisplayMetrics().density * 59);

        root.invalidate();
        text.clearFocus();
        text.setSingleLine(true);
        text.setVerticalScrollBarEnabled(false);

      case HIDDEN:
        hideKeyboard();
        break;

      case EXPANDED:
        if (!collapsed) return;
        if (getView() == null) return;
        collapsed = false;
        ((RelativeLayout.LayoutParams) send.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            0;
        ((RelativeLayout.LayoutParams) target.getLayoutParams())
                .getRules()[RelativeLayout.ALIGN_BOTTOM] =
            R.id.send;
        ((RelativeLayout.LayoutParams) text.getLayoutParams()).getRules()[RelativeLayout.LEFT_OF] =
            0;

        ((CoordinatorLayout.LayoutParams) commentFrame.getLayoutParams()).rightMargin = 0;
        root.invalidate();
        text.setVerticalScrollBarEnabled(true);
        text.setSingleLine(false);
        text.setMaxLines(9);

        showKeyboard();
        break;
    }
  }
Esempio n. 22
0
 @Test
 public void addViewWithLayoutParams_shouldStoreLayoutParams() throws Exception {
   FrameLayout.LayoutParams layoutParams1 =
       new FrameLayout.LayoutParams(
           ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   FrameLayout.LayoutParams layoutParams2 =
       new FrameLayout.LayoutParams(
           ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   ImageView child1 = new ImageView(Robolectric.application);
   ImageView child2 = new ImageView(Robolectric.application);
   root.addView(child1, layoutParams1);
   root.addView(child2, 1, layoutParams2);
   assertSame(layoutParams1, child1.getLayoutParams());
   assertSame(layoutParams2, child2.getLayoutParams());
 }
  private void addIconTabBådeTekstOgBillede(
      final int position, int resId, Bitmap res, String title) {
    FrameLayout tabfl = new FrameLayout(getContext());
    if (Build.VERSION.SDK_INT > 11) tabfl.setLayoutTransition(new LayoutTransition());
    ImageView tabi = new ImageView(getContext());
    tabi.setContentDescription(title);
    if (res != null) {
      tabi.setImageBitmap(res);
      tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      tabi.setAdjustViewBounds(true);
    } else {
      tabi.setImageResource(resId);
    }
    tabi.setVisibility(View.GONE);
    TextView tabt = new TextView(getContext());
    tabt.setText(title);
    tabt.setTypeface(App.skrift_gibson);
    tabt.setGravity(Gravity.CENTER);
    tabt.setSingleLine();

    tabfl.addView(tabi);
    tabfl.addView(tabt);

    LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
    lp.gravity = Gravity.CENTER;
    lp = (LayoutParams) tabt.getLayoutParams();
    lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.gravity = Gravity.CENTER;

    addTab(position, tabfl);
  }
Esempio n. 24
0
  /**
   * 根据ImageView获得适当的压缩的宽和高
   *
   * @param imageView
   * @return
   */
  private ImageSize getImageViewWidth(ImageView imageView) {
    ImageSize imageSize = new ImageSize();
    final DisplayMetrics displayMetrics = imageView.getContext().getResources().getDisplayMetrics();
    final LayoutParams params = imageView.getLayoutParams();

    int width =
        params.width == LayoutParams.WRAP_CONTENT
            ? 0
            : imageView.getWidth(); // Get actual image width
    if (width <= 0) width = params.width; // Get layout width parameter
    if (width <= 0) width = getImageViewFieldValue(imageView, "mMaxWidth"); // Check
    // maxWidth
    // parameter
    if (width <= 0) width = displayMetrics.widthPixels;
    int height =
        params.height == LayoutParams.WRAP_CONTENT
            ? 0
            : imageView.getHeight(); // Get actual image height
    if (height <= 0) height = params.height; // Get layout height parameter
    if (height <= 0) height = getImageViewFieldValue(imageView, "mMaxHeight"); // Check
    // maxHeight
    // parameter
    if (height <= 0) height = displayMetrics.heightPixels;
    imageSize.width = width;
    imageSize.height = height;
    return imageSize;
  }
Esempio n. 25
0
 /**
  * 用于内部子控件超出控件本身范围滑动的监听
  *
  * @param deltaX X 轴的滑动距离
  * @param deltaY Y 轴的滑动距离,顶部超出的时候为负,底部超出的时候为正
  * @param scrollX
  * @param scrollY
  * @param scrollRangeX
  * @param scrollRangeY
  * @param maxOverScrollX
  * @param maxOverScrollY
  * @param isTouchEvent
  * @return
  */
 @Override
 protected boolean overScrollBy(
     int deltaX,
     int deltaY,
     int scrollX,
     int scrollY,
     int scrollRangeX,
     int scrollRangeY,
     int maxOverScrollX,
     int maxOverScrollY,
     boolean isTouchEvent) {
   Log.e("listview", "deltaY=======" + deltaY);
   if (deltaY < 0 && isTouchEvent) { // 如果是手指拖动到达顶部并且下拉
     int height = imageView.getHeight() - deltaY / 2; // imagview 变化后的高度
     totalY -= deltaY; // 将滑动的距离添加给滑动总距离
     if (height < MaxOverY) { // 如果当前控件的高度小于可滑动的最大值
       imageView.getLayoutParams().height = height;
       imageView.requestLayout(); // 设置高度后请求重新绘制位置
     }
   }
   return super.overScrollBy(
       deltaX,
       deltaY,
       scrollX,
       scrollY,
       scrollRangeX,
       scrollRangeY,
       maxOverScrollX,
       maxOverScrollY,
       isTouchEvent);
 }
Esempio n. 26
0
  @Override
  public View getView(int position, View convertView, ViewGroup container) {
    // ImageView thumbnails
    ImageView imageView;
    if (convertView == null) {
      // if it's not recycled, instantiate and initialize
      imageView = new RecyclingImageView(mContext);
      imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
      imageView.setLayoutParams(mImageViewLayoutParams);
    } else {
      // Otherwise re-use the converted view
      imageView = (ImageView) convertView;
    }

    // Check the height matches our calculated column width
    if (imageView.getLayoutParams().height != mItemHeight) {
      imageView.setLayoutParams(mImageViewLayoutParams);
    }

    // Finally load the image asynchronously into the ImageView, this also
    // takes care of setting a placeholder image while the background thread
    // runs
    mImageFetcher.loadImage(getItem(position), imageView);
    return imageView;
  }
Esempio n. 27
0
  public UserDetail(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.linearlayout_userdetail, this);
    imageviewbili = (ImageView) findViewById(R.id.littletv);
    imageviewbili.setOnTouchListener(this);
    imageviewbili.setBackgroundResource(R.drawable.bili_up);
    ImageView usericon = (ImageView) findViewById(R.id.usericon);
    TextView textview = (TextView) findViewById(R.id.username);

    RelativeLayout.LayoutParams layoutParamsb =
        (RelativeLayout.LayoutParams) imageviewbili.getLayoutParams();
    layoutParamsb.height = (int) (MainActivity.window_height * 3 / 11 / 1.5);
    layoutParamsb.width = 270 * layoutParamsb.height / 208;
    imageviewbili.setLayoutParams(layoutParamsb);

    StyleController.contextinStyleController = context;
    setusernametextTheme(textview);
    data = getData();
    UserDetailAdapter adapter = new UserDetailAdapter(context);
    lv = (ListView) findViewById(R.id.userlv);
    lv.setAdapter(adapter);
    lv.setDividerHeight(1);
  }
Esempio n. 28
0
  @Override
  public View getView(int arg0, View arg1, ViewGroup arg2) {
    // TODO Auto-generated method stub
    if (arg1 == null) {
      arg1 = LayoutInflater.from(context).inflate(R.layout.encircle_item_layout, null);
    }
    //		ImageView faceImg = ViewHolder.get(arg1, R.id.face_img);

    ImageView itemImg = ViewHolder.get(arg1, R.id.item_img);

    itemImg.getLayoutParams().width = sGirdImageSize;
    itemImg.getLayoutParams().height = sGirdImageSize;

    //		ImageView faceImg = ViewHolder.get(arg1, R.id.face_img);
    //		ImageLoader.getInstance().displayImage("drawable://" + R.drawable.face_test1, itemImg,
    // options);
    ImageLoader.getInstance()
        .displayImage(
            "http://d.hiphotos.baidu.com/image/pic/item/b64543a98226cffc2d1e40b8ba014a90f603ea80.jpg",
            itemImg,
            options);

    View tmp_view = ViewHolder.get(arg1, R.id.tmp_view);
    if (arg0 == mListItems.size() - 1) {
      tmp_view.setVisibility(View.INVISIBLE);
    } else {
      tmp_view.setVisibility(View.GONE);
    }
    return arg1;
  }
Esempio n. 29
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      // Inflate the layout, mainlvitem.xml, in each row.
      LayoutInflater inflater = FriendList.this.getLayoutInflater();
      View row = inflater.inflate(R.layout.user_friends_item, parent, false);
      ((TextView) row.findViewById(R.id.textView1)).setText(name.get(position));

      ImageView img = (ImageView) row.findViewById(R.id.imageView1);
      img.getLayoutParams().height = hgt;
      il.DisplayImage(image.get(position), img);

      img.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              // TODO Auto-generated method stub
              Intent in = new Intent(FriendList.this, Chat.class);
              in.putExtra("fid", frdid.get(position));
              in.putExtra("fname", name.get(position));
              startActivity(in);
            }
          });
      return row;
    }
Esempio n. 30
0
 private void setViewSize() {
   WindowManager m = getWindowManager();
   Display d = m.getDefaultDisplay();
   ViewGroup.LayoutParams params = previewImage.getLayoutParams();
   params.height = (int) (d.getHeight() * 0.3);
   previewImage.setLayoutParams(params);
 }