There are various XML attributes for ImageView to scale its content , and various layout views that allow to place views and set their sizes.
Howeve
You can use is custom FitWidthAtBottomImageView
to achieve this code:
public class FitWidthAtBottomImageView extends ImageView {
public FitWidthAtBottomImageView(Context context) {
super(context);
}
public FitWidthAtBottomImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public FitWidthAtBottomImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public FitWidthAtBottomImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
@Override
protected void onDraw(Canvas canvas) {
int i = getWidth() - getPaddingLeft() - getPaddingRight();
int j = getHeight() - getPaddingTop() - getPaddingBottom();
if (getBackground() != null) {
getBackground().draw(canvas);
}
if (getDrawable() != null && getDrawable() instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable) getDrawable()).getBitmap();
int h = bitmap.getHeight() * i / bitmap.getWidth();
canvas.drawBitmap(bitmap, null, new RectF(getPaddingLeft(), getPaddingTop() + j - h, getPaddingLeft() + i, getHeight() - getPaddingBottom()), null);
} else {
super.onDraw(canvas);
}
}
}
by manually draw the bottom aligned image that you want.