android.widget.ImageButton.getWidth()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中android.widget.ImageButton.getWidth()方法的一些代码示例,展示了ImageButton.getWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.getWidth()方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:getWidth

ImageButton.getWidth介绍

暂无

代码示例

代码示例来源:origin: nickbutcher/plaid

void revealPostingProgress() {
  Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting,
      (int) fabPosting.getPivotX(),
      (int) fabPosting.getPivotY(),
      0f,
      fabPosting.getWidth() / 2)
      .setDuration(600L);
  reveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(this));
  reveal.start();
  AnimatedVectorDrawable uploading =
      (AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading);
  if (uploading != null) {
    fabPosting.setImageDrawable(uploading);
    uploading.start();
  }
}

代码示例来源:origin: asyl/ArcAnimator

void appearRed() {
  mRed.setVisibility(View.VISIBLE);
  int cx = mRed.getWidth() / 2;
  int cy = mRed.getHeight() / 2;
  SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mRed, cx, cy, 0, mRed.getWidth() / 2);
  animator.addListener(new SimpleListener() {
    @Override
    public void onAnimationEnd() {
      upRed();
    }
  });
  animator.setInterpolator(ACCELERATE);
  animator.start();
}

代码示例来源:origin: asyl/ArcAnimator

void disappearRed() {
  int cx = mRed.getWidth() / 2;
  int cy = mRed.getHeight() / 2;
  SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mRed, cx, cy, mRed.getWidth() / 2, 0);
  animator.addListener(new SimpleListener() {
    @Override
    public void onAnimationEnd() {
      mRed.setVisibility(View.INVISIBLE);
      mRed.setX(startRedX);
      mRed.setY(startRedY);
      release();
    }
  });
  animator.setInterpolator(DECELERATE);
  animator.start();
}

代码示例来源:origin: asyl/ArcAnimator

void appearBluePair() {
  mBluePair.setVisibility(View.VISIBLE);
  float finalRadius = Math.max(mBluePair.getWidth(), mBluePair.getHeight()) * 1.5f;
  SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mBluePair, endBlueX, endBlueY, mBlue.getWidth() / 2f,
      finalRadius);
  animator.setDuration(500);
  animator.setInterpolator(ACCELERATE);
  animator.addListener(new SimpleListener() {
    @Override
    public void onAnimationEnd() {
      raise();
    }
  });
  animator.start();
}

代码示例来源:origin: asyl/ArcAnimator

void disappearBluePair() {
  float finalRadius = Math.max(mBluePair.getWidth(), mBluePair.getHeight()) * 1.5f;
  SupportAnimator animator = ViewAnimationUtils.createCircularReveal(mBluePair, endBlueX, endBlueY,
      finalRadius, mBlue.getWidth() / 2f);
  animator.setDuration(500);
  animator.addListener(new SimpleListener() {
    @Override
    public void onAnimationEnd() {
      mBluePair.setVisibility(View.INVISIBLE);
      returnBlue();
    }
  });
  animator.setInterpolator(DECELERATE);
  animator.start();
}

代码示例来源:origin: stackoverflow.com

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  ImageButton ib = (ImageButton) findViewById(R.id.myImageButton);
  ib.setMaxHeight(ib.getWidth());

  //the rest of your onCreate method...
}

代码示例来源:origin: redfish64/TinyTravelTracker

protected void initWithWorkingGetWidth() {
  slideSasFullToTab = new TranslateAnimation(0, sasPanelButton.getWidth() - sasPanel.getWidth(), 0, 0);
  slideSasTabToFull = new TranslateAnimation(sasPanelButton.getWidth() - sasPanel.getWidth(), 0, 0, 0);
  slideSasTabToNone = new TranslateAnimation(sasPanelButton.getWidth() - sasPanel.getWidth(), - sasPanel.getWidth(), 0, 0);
  slideSasFullToNone = new TranslateAnimation(0, -sasPanel.getWidth(), 0, 0);
  slideSasNoneToFull = new TranslateAnimation(-sasPanel.getWidth(), 0, 0, 0);
  slideSasNoneToTab = new TranslateAnimation(-sasPanel.getWidth(),
      sasPanelButton.getWidth() - sasPanel.getWidth(), 0, 0);
  
  slideSasFullToTab.setDuration(500);
  slideSasTabToFull.setDuration(500);
  slideSasTabToNone.setDuration(200);
  slideSasFullToNone.setDuration(500);
  slideSasNoneToFull.setDuration(500);
  slideSasNoneToTab.setDuration(200);
  
  osmMapView.setZoomCenter(osmMapView.getWidth()/2,
      findViewById(R.id.timeview_layout).getTop()/2);
}

代码示例来源:origin: Shirlman/YiPlayer

@Override
  public void onClick(View v) {
    View videoControllerTop = mVideoControllerRootView.findViewById(R.id.video_controller_top);
    View videoControllerBottom = mVideoControllerRootView.findViewById(R.id.video_controller_bottom);
    View videoControllerRight = mVideoControllerRootView.findViewById(R.id.video_controller_right);
    mIsLocked = !mIsLocked;
    int lockImageSize;
    if(mIsLocked) {
      mDefaultLockImageSize = mVideoControllerVideoLock.getWidth();
      lockImageSize = (int)(mDefaultLockImageSize * 1.5);
      videoControllerTop.setVisibility(View.INVISIBLE);
      videoControllerBottom.setVisibility(View.INVISIBLE);
      videoControllerRight.setVisibility(View.INVISIBLE);
    } else {
      lockImageSize = mDefaultLockImageSize;
      videoControllerTop.setVisibility(View.VISIBLE);
      videoControllerBottom.setVisibility(View.VISIBLE);
      videoControllerRight.setVisibility(View.VISIBLE);
    }
    ViewGroup.LayoutParams layoutParams = mVideoControllerVideoLock.getLayoutParams();
    layoutParams.width = lockImageSize;
    layoutParams.height = lockImageSize;
    mVideoControllerVideoLock.setLayoutParams(layoutParams);
    startHideVideoControllerTimer();
  }
};

代码示例来源:origin: stackoverflow.com

private void setupBalloon(ImageButton b, int i) {
  int imageId = (int)(Math.random() * images.length);
  LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
      LinearLayout.LayoutParams.WRAP_CONTENT);
  b.setLayoutParams(params);
  b.setImageResource(images[imageId]);
  b.setBackgroundColor(Color.TRANSPARENT);
  b.setScaleX(0.4f);
  b.setScaleY(0.4f);
  b.setX((float) (Math.random() * (width - b.getWidth())));
  b.setY((float) (Math.random() * (height - b.getHeight())));
  b.setVisibility(View.VISIBLE);
}

代码示例来源:origin: stackoverflow.com

final ImageButton button = (ImageButton) findViewById(R.id.my_button);
final LinearLayout button_container = (LinearLayout) findViewById(R.id.my_window);

button.setOnClickListener(new OnClickListener() {
  public void onClick (View v) {

    // change button image
    int imgNo = (int) (Math.random() * 9) + 1; // 9 images in the folder, start at index 1
    int imgID = getResources().getIdentifier("chef" + imgNo, "drawable", getPackageName());
    button.setBackgroundResource(imgID);
    button.requestLayout(); // size to fit content

    // move button to a random location
    int x = (int) (Math.random() * (button_container.getWidth() - button.getWidth()));
    int y = (int) (Math.random() * (button_container.getHeight() - button.getHeight()));
    button_container.setPadding(x, y, 0, 0);
  }   
});
button.performClick(); // run once at the start to set image and position randomly

代码示例来源:origin: stackoverflow.com

if (toolbar.getChildAt(i).getClass() == ImageButton.class) {
  imageButton = (ImageButton) toolbar.getChildAt(i);
  padding -= imageButton.getWidth();
  break;

代码示例来源:origin: SmartDengg/SmartDrawing

@Override public boolean onPreDraw() {
  toolbar.getViewTreeObserver().removeOnPreDrawListener(this);
  Toolbar.LayoutParams layoutParams = (Toolbar.LayoutParams) titleTv.getLayoutParams();
  layoutParams.leftMargin = navButtonView.getWidth();
  toolbar.setNavigationIcon(null);
  return true;
 }
});

代码示例来源:origin: Calsign/APDE

protected void showCharInserts() {
    TextView messageView = (TextView) findViewById(R.id.message);
    HorizontalScrollView charInsertTray = (HorizontalScrollView) findViewById(R.id.char_insert_tray);
    
    View buffer = findViewById(R.id.buffer);
    
    View sep = findViewById(R.id.toggle_char_inserts_separator);
    
    toggleCharInserts.setImageResource(errorMessage ? R.drawable.ic_caret_right_white : R.drawable.ic_caret_right_black);
//        ((TextView) findViewById(R.id.message)).setVisibility(View.GONE);
//        ((HorizontalScrollView) findViewById(R.id.char_insert_tray)).setVisibility(View.VISIBLE);
    
    int total = buffer.getWidth() - sep.getWidth() - toggleCharInserts.getWidth();
    
    RotateAnimation rotate = new RotateAnimation(180f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setInterpolator(new AccelerateDecelerateInterpolator());
    rotate.setRepeatCount(0);
    rotate.setDuration(200);
    
    messageView.startAnimation(new ResizeAnimation<LinearLayout>(messageView, ResizeAnimation.DEFAULT, ResizeAnimation.DEFAULT, 0, ResizeAnimation.DEFAULT));
    charInsertTray.startAnimation(new ResizeAnimation<LinearLayout>(charInsertTray, 0, buffer.getHeight(), total, buffer.getHeight()));
    toggleCharInserts.startAnimation(rotate);
    
    charInserts = true;
  }

代码示例来源:origin: Calsign/APDE

protected void hideCharInserts() {
  if (!(keyboardVisible && charInserts)) {
    // No need to hide them if they're already hidden
    return;
  }
  
  TextView messageView = (TextView) findViewById(R.id.message);
  HorizontalScrollView charInsertTray = (HorizontalScrollView) findViewById(R.id.char_insert_tray);
  
  View buffer = findViewById(R.id.buffer);
  
  View sep = findViewById(R.id.toggle_char_inserts_separator);

  toggleCharInserts.setImageResource(errorMessage ? R.drawable.ic_caret_left_white : R.drawable.ic_caret_left_black);
  
  int total = buffer.getWidth() - sep.getWidth() - toggleCharInserts.getWidth();
  
  RotateAnimation rotate = new RotateAnimation(180f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
  rotate.setInterpolator(new AccelerateDecelerateInterpolator());
  rotate.setRepeatCount(0);
  rotate.setDuration(200);
  
  messageView.startAnimation(new ResizeAnimation<LinearLayout>(messageView, 0, buffer.getHeight(), total, buffer.getHeight()));
  charInsertTray.startAnimation(new ResizeAnimation<LinearLayout>(charInsertTray, ResizeAnimation.DEFAULT, ResizeAnimation.DEFAULT, 0, ResizeAnimation.DEFAULT));
  toggleCharInserts.startAnimation(rotate);
  
  charInserts = false;
}

代码示例来源:origin: CUTR-at-USF/OpenTripPlanner-for-Android

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public void onGlobalLayout() {
    MainFragment.removeOnGlobalLayoutListener(mainView, this);
    int locationTbEndLocation[] = new int[2];
    mTbEndLocation.getLocationInWindow(locationTbEndLocation);
    int locationItinerarySelectionSpinner[] = new int[2];
    mItinerarySelectionSpinner
        .getLocationInWindow(locationItinerarySelectionSpinner);
    int locationBtnHandle[] = new int[2];
    mBtnHandle.getLocationInWindow(locationBtnHandle);
    DisplayMetrics metrics = MainFragment.this.getResources()
        .getDisplayMetrics();
    int windowHeight = metrics.heightPixels;
    int paddingMargin = MainFragment.this.getResources()
        .getInteger(R.integer.map_padding_margin);
    mMapPaddingLeft = locationBtnHandle[0] + mBtnHandle.getWidth() / 2
        + paddingMargin;
    mMapPaddingTop = locationTbEndLocation[1] + mTbEndLocation.getHeight() / 2
        + paddingMargin;
    mMapPaddingRight = 0;
    mMapPaddingBottom = windowHeight - locationItinerarySelectionSpinner[1]
        + paddingMargin;
    if (mMap != null) {
      mMap.setPadding(mMapPaddingLeft, mMapPaddingTop, mMapPaddingRight, mMapPaddingBottom);
    }
  }
});

代码示例来源:origin: gateship-one/odyssey

/**
 * Called if the position of the draggable view is changed. This rerequests the layout of the view.
 *
 * @param changedView The view that was changed.
 * @param left        Left position of the view (should stay constant in this case)
 * @param top         Top position of the view
 * @param dx          Dimension of the width
 * @param dy          Dimension of the height
 */
@Override
public void onViewPositionChanged(@NonNull View changedView, int left, int top, int dx, int dy) {
  // Save the heighest top position of this view.
  mTopPosition = top;
  // Calculate the new drag offset
  mDragOffset = (float) top / mDragRange;
  // Relayout this view
  requestLayout();
  // Set inverse alpha values for smooth layout transition.
  // Visibility still needs to be set otherwise parts of the buttons
  // are not clickable.
  mDraggedDownButtons.setAlpha(mDragOffset);
  mDraggedUpButtons.setAlpha(1.0f - mDragOffset);
  // Calculate the margin to smoothly resize text field
  RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mHeaderTextLayout.getLayoutParams();
  layoutParams.setMarginEnd((int) (mTopPlaylistButton.getWidth() * (1.0 - mDragOffset)));
  mHeaderTextLayout.setLayoutParams(layoutParams);
  if (mDragStatusReceiver != null) {
    mDragStatusReceiver.onDragPositionChanged(mDragOffset);
  }
}

代码示例来源:origin: stackoverflow.com

public void run() {
  maxX = imageButton.getRootView()
    .getRight() - imageButton.getWidth();
  maxY = imageButton.getRootView()
    .getBottom() - imageButton.getHeight();

代码示例来源:origin: gateship-one/odyssey

layoutParams.setMarginEnd((int) (mTopPlaylistButton.getWidth() * (1.0 - mDragOffset)));
mHeaderTextLayout.setLayoutParams(layoutParams);

代码示例来源:origin: stackoverflow.com

Class<?> c;
 ImageButton imageButton;
 AppCompatImageButton appCompatImageButton;
 for (int i = 0; i < toolbar.getChildCount(); i++) {
   c = toolbar.getChildAt(i).getClass();
   if (c == AppCompatImageButton.class) {
     appCompatImageButton = (AppCompatImageButton) toolbar.getChildAt(i);
     padding -= appCompatImageButton.getWidth()*1.3;
     padding -= appCompatImageButton.getPaddingLeft();
     padding -= appCompatImageButton.getPaddingRight();
     if (appCompatImageButton.getLayoutParams().getClass() == LinearLayout.LayoutParams.class) {
       padding -= ((LinearLayout.LayoutParams) appCompatImageButton.getLayoutParams()).getMarginEnd();
       padding -= ((LinearLayout.LayoutParams) appCompatImageButton.getLayoutParams()).getMarginStart();
     }
     break;
   }
   else if (c == ImageButton.class) {
     imageButton = (ImageButton) toolbar.getChildAt(i);
     padding -= imageButton.getWidth();
     padding -= imageButton.getPaddingLeft();
     padding -= imageButton.getPaddingRight();
     if (imageButton.getLayoutParams().getClass() == LinearLayout.LayoutParams.class) {
       padding -= ((LinearLayout.LayoutParams) imageButton.getLayoutParams()).getMarginEnd();
       padding -= ((LinearLayout.LayoutParams) imageButton.getLayoutParams()).getMarginStart();
     }
     break;
   }
 }

代码示例来源:origin: PuffOpenSource/Puff-Android

buttonNext.setTranslationY(-2 * buttonNext.getHeight());
pagerIndicator.setTranslationY(offset * 2 * buttonNext.getWidth());
updateButtonNextDrawable();

相关文章

ImageButton类方法