本文整理汇总了Java中android.widget.ImageView.getDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.getDrawable方法的具体用法?Java ImageView.getDrawable怎么用?Java ImageView.getDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.getDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDisplayMatrix
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public boolean setDisplayMatrix(Matrix finalMatrix) {
if (finalMatrix == null)
throw new IllegalArgumentException("Matrix cannot be null");
ImageView imageView = getImageView();
if (null == imageView)
return false;
if (null == imageView.getDrawable())
return false;
mSuppMatrix.set(finalMatrix);
setImageViewMatrix(getDrawMatrix());
checkMatrixBounds();
return true;
}
示例2: getFitCenterScaleFactor
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Calculates the scale factor needed to scale a drawable to fill one view dimension while
* the other drawable dimension maintains the correct aspect ratio while remaining inside the
* view.
*
* @param imageView the view with a drawable to be centered
* @return the scale factor
*/
private static float getFitCenterScaleFactor(@Nullable ImageView imageView) {
if (imageView == null || imageView.getDrawable() == null) {
return NO_SCALE;
}
Drawable drawable = imageView.getDrawable();
int drawableWidth = drawable.getIntrinsicWidth();
int drawableHeight = drawable.getIntrinsicHeight();
int viewWidth = getViewWidthMinusPadding(imageView);
int viewHeight = getViewHeightMinusPadding(imageView);
if (drawableWidth <= 0 || drawableHeight <= 0 || viewWidth <= 0 || viewHeight <= 0) {
return NO_SCALE;
}
float xScaling = ((float) viewWidth) / drawableWidth;
float yScaling = ((float) viewHeight) / drawableHeight;
// Always just pick the smallest dimension
return Math.min(xScaling, yScaling);
}
示例3: computeImageWidthAndHeight
import android.widget.ImageView; //导入方法依赖的package包/类
/** 计算图片的宽高 */
private void computeImageWidthAndHeight(ImageView imageView) {
// 获取真实大小
Drawable drawable = imageView.getDrawable();
int intrinsicHeight = drawable.getIntrinsicHeight();
int intrinsicWidth = drawable.getIntrinsicWidth();
// 计算出与屏幕的比例,用于比较以宽的比例为准还是高的比例为准,因为很多时候不是高度没充满,就是宽度没充满
float h = screenHeight * 1.0f / intrinsicHeight;
float w = screenWidth * 1.0f / intrinsicWidth;
if (h > w) h = w;
else w = h;
// 得出当宽高至少有一个充满的时候图片对应的宽高
imageHeight = (int) (intrinsicHeight * h);
imageWidth = (int) (intrinsicWidth * w);
}
示例4: Builder
import android.widget.ImageView; //导入方法依赖的package包/类
public Builder(ImageView imageView) {
viewRef = new WeakReference<>(imageView);
if (imageView.getScaleType() != ImageView.ScaleType.MATRIX) {
throw new IllegalStateException("the image scaleType must be ScaleType.MATRIX");
}
Drawable d = imageView.getDrawable();
if (d != null) {
animCenterX = d.getIntrinsicWidth() / 2;
animCenterY = d.getIntrinsicHeight() / 2;
}
Matrix matrix = new Matrix(imageView.getImageMatrix());
fromDegrees = toDegrees = MatrixUtils.getMatrixAngle(matrix);
fromScaleX = toScaleX = getMatrixScaleX(matrix);
fromScaleY = toScaleY = getMatrixScaleY(matrix);
float[] txty = calculateTxTy();
fromTranslateX = toTranslateX = txty[0];
fromTranslateY = toTranslateY = txty[1];
}
示例5: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_result);
final TextView search_result_back = (TextView) findViewById(R.id.search_result_back);
final ListView search_result_list = (ListView) findViewById(R.id.search_result_list);
img = (ImageView) findViewById(R.id.imageView3);
ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, Item.searchList);
search_result_list.setAdapter(adapter);
TransitionDrawable animation = (TransitionDrawable)img.getDrawable();
animation.startTransition(3000);
animation.reverseTransition(3000);
// img.setBackgroundResource(R.drawable.trans);
// AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
// frameAnimation.start();
search_result_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Item.searchList.clear();
goToSearch();
}
});
}
示例6: getRefreshHeaderView
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public View getRefreshHeaderView() {
if (mRefreshHeaderView == null) {
mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_normal, null);
mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
if (mRefreshViewBackgroundColorRes != -1) {
mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
}
if (mRefreshViewBackgroundDrawableRes != -1) {
mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
}
mHeaderStatusTv = (TextView) mRefreshHeaderView.findViewById(R.id.tv_normal_refresh_header_status);
mHeaderArrowIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_arrow);
mHeaderChrysanthemumIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_chrysanthemum);
mHeaderChrysanthemumAd = (AnimationDrawable) mHeaderChrysanthemumIv.getDrawable();
mHeaderStatusTv.setText(mPullDownRefreshText);
}
return mRefreshHeaderView;
}
示例7: convertTargetInfo
import android.widget.ImageView; //导入方法依赖的package包/类
void convertTargetInfo(ImageView tarView, Context context) {
if (tarView == null || tarView.getDrawable() == null) {
throw new NullPointerException("target ImageView or ImageView drawable must not null");
}
//get target ImageView info
tarView.getImageMatrix().getValues(mTargetValues);
Rect tarRect = tarView.getDrawable().getBounds();
mTargetWidth = (int) (tarRect.width() * mTargetValues[Matrix.MSCALE_X]);
mTargetHeight = (int) (tarRect.height() * mTargetValues[Matrix.MSCALE_Y]);
mTargetViewWidth = tarView.getWidth();
mTargetViewHeight = tarView.getHeight();
tarView.getLocationOnScreen(mTargetLocation);
init(context);
}
示例8: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open_on_phone_animation);
AmbientMode.attachAmbientSupport(this);
mAnimationCallback =
new AnimationCallback() {
@Override
public void onAnimationEnd(Drawable drawable) {
super.onAnimationEnd(drawable);
// Go back to main Dialogs screen after animation.
finish();
}
};
// Play 'swipe left' animation only once.
ImageView phoneImage = findViewById(R.id.open_on_phone_animation_image);
mAnimatedVectorDrawablePhone = (AnimatedVectorDrawable) phoneImage.getDrawable();
mAnimatedVectorDrawablePhone.registerAnimationCallback(mAnimationCallback);
mAnimatedVectorDrawablePhone.start();
}
开发者ID:googlesamples,项目名称:android-WearAccessibilityApp,代码行数:24,代码来源:OpenOnPhoneAnimationActivity.java
示例9: getDisplayRect
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Helper method that maps the supplied Matrix to the current Drawable
*
* @param matrix
* - Matrix to map Drawable against
* @return RectF - Displayed Rectangle
*/
private RectF getDisplayRect(Matrix matrix) {
ImageView imageView = getImageView();
if (null != imageView) {
Drawable d = imageView.getDrawable();
if (null != d) {
mDisplayRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
matrix.mapRect(mDisplayRect);
return mDisplayRect;
}
}
return null;
}
示例10: getDisplayRect
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Helper method that maps the supplied Matrix to the current Drawable
*
* @param matrix - Matrix to map Drawable against
* @return RectF - Displayed Rectangle
*/
private RectF getDisplayRect(Matrix matrix) {
ImageView imageView = getImageView();
if (null != imageView) {
Drawable d = imageView.getDrawable();
if (null != d) {
mDisplayRect.set(0, 0, d.getIntrinsicWidth(),
d.getIntrinsicHeight());
matrix.mapRect(mDisplayRect);
return mDisplayRect;
}
}
return null;
}
示例11: convertOriginalInfo
import android.widget.ImageView; //导入方法依赖的package包/类
public void convertOriginalInfo(ImageView oriView) {
if (oriView == null || oriView.getDrawable() == null) {
throw new NullPointerException("original ImageView or ImageView drawable must not null");
}
//get original ImageView info
oriView.getImageMatrix().getValues(mOriginalValues);
Rect oriRect = oriView.getDrawable().getBounds();
mOriginalWidth = (int) (oriRect.width() * mOriginalValues[Matrix.MSCALE_X]);
mOriginalHeight = (int) (oriRect.height() * mOriginalValues[Matrix.MSCALE_Y]);
mOriginalViewWidth = oriView.getWidth();
mOriginalViewHeight = oriView.getHeight();
oriView.getLocationOnScreen(mOriginalLocation);
}
示例12: startAnimationDrawable
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* 播放帧动画
*
* @param target target
* @return
*/
public static AnimationDrawable startAnimationDrawable(ImageView target) {
AnimationDrawable animationDrawable = (AnimationDrawable) target.getDrawable();
if (animationDrawable != null) {
target.setVisibility(View.VISIBLE);
animationDrawable.start();
}
return animationDrawable;
}
示例13: getBase64
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* Se transforma el contenido de un ImageView en un String base64 para enviar al servidor.
*
* @param imageView
* @return
*/
public String getBase64(ImageView imageView) {
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
Bitmap bitmap = drawable.getBitmap();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bb = bos.toByteArray();
String image = Base64.encodeToString(bb, 0);
return image;
}
示例14: initView
import android.widget.ImageView; //导入方法依赖的package包/类
public void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.yun_refresh_footer, this);
mText = (TextView) findViewById(R.id.msg);
mIvProgress = (ImageView) findViewById(R.id.iv_progress);
mAnimationDrawable = (AnimationDrawable) mIvProgress.getDrawable();
if (!mAnimationDrawable.isRunning()) {
mAnimationDrawable.start();
}
setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
示例15: hasDrawable
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* @return true if the ImageView exists, and it's Drawable existss
*/
private static boolean hasDrawable(ImageView imageView) {
return null != imageView && null != imageView.getDrawable();
}