android - Reference different raw resource depending on screen orientation -


i define raw resources in dimens.xml file define margins, padding different screen orientations.

i've tried this:

<item name="my_res" type="raw" format="string">r.raw.test</item>

but doesn't seem working.

when try fetch id of resource, not correct:

    typedvalue out = new typedvalue();      getresources().getvalue(r.raw.my_res, out, true);     int resid = out.resourceid; 

any suggestions how han

use activity.getresources().getconfiguration().orientation obtaining orientation_portrait , orientation_landscape values indicating current orientation. based on this, appropiate raw resource.

typedvalue out = new typedvalue(); int resid; if(activity.getresources().getconfiguration().orientation == 1) { //1 portrait , 2 landscape      getresources().getvalue(r.raw.my_res, out, true);     resid = out.resourceid; } else {     getresources().getvalue(r.raw.my_res_alternate, out, true);     resid = out.resourceid; } 

do necesary change, main idea.


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -