afaik you cannot do that in xml, the only way is to create a custom class extending Drawable that would react on orientarion changes for example:
class D extends Drawable {
private Bitmap mBitmap;
private Matrix mMatrix;
private boolean mIsLandscape;
public D(Resources res, Bitmap b) {
mBitmap = b;
mMatrix = new Matrix();
mIsLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
}
@Override
protected void onBoundsChange(Rect bounds) {
RectF src = new RectF(0, 0, mBitmap.getWidth(), mBitmap.getHeight());
RectF dst = new RectF();
if (!mIsLandscape) {
dst.set(0, 0, bounds.width(), bounds.height());
} else {
dst.set(0, 0, bounds.height(), bounds.width());
}
mMatrix.setRectToRect(src, dst, ScaleToFit.FILL);
if (mIsLandscape) {
mMatrix.postRotate(-90);
mMatrix.postTranslate(0, bounds.height());
}
}
@Override
public void draw(Canvas canvas) {
canvas.drawBitmap(mBitmap, mMatrix, null);
}
@Override
public void setAlpha(int alpha) {
}
@Override
public void setColorFilter(ColorFilter cf) {
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
}