drawable-land vs drawable

ぃ、小莉子 提交于 2019-12-08 07:47:00

问题


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 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)


回答1:


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



来源:https://stackoverflow.com/questions/6763977/drawable-land-vs-drawable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!