开发者

drawable-land vs drawable

开发者 https://www.devze.com 2023-03-22 04:34 出处:网络
I am not using a layout-land, but do have drawable-land. The problem is, it uses whichever drawable matches the orientation when the activity starts.I would like it to switch between using the drawab

I am not using a layout-land, but do have drawable-land.

The problem is, it uses whichever drawable matches the orientation when the activity starts. I would like it to switch between using the drawable/drawable-land when the开发者_如何学C phone rotates. Is there a way to do this easily? Or should I just copy and paste my layout into layout-land, so that it actually recreates the activity? (I assume that would do the right thing, but ideally I would like it to just refresh the drawable using the correct one when I rotate)


you can check first device orientation ie manually by

Display mDisplay= activity.getWindowManager().getDefaultDisplay();
int width= mDisplay.getWidth();
int Height= mDisplay.getHeight();

if(width>height)
{
//Landscape
//set your landscape drawable
}
else
{
//portrait
//set your portrait drawable
}

so then no need to create "Drawable-land" folder also

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号