scrolling and swiping problem in android
In my project i am 开发者_JAVA百科rendering pdf, in landscape mode i am fitting to pagewidth and in portrait mode i am fitting to pageheight mode. can anybody suggest me how to do scrolling in landscape mode only and swiping in both orientations. thank you in advance..
I would say the easiest way of doing this, assuming the scrolling is defines in your XML, is to create different layouts for each. somename_land.xml in the layout-land folder would have scrolling defined while somename_port.xml in layout-port would not. Both would have swiping. You then select the context in your code with something like this:
WindowManager winMan = (WindowManager) getBaseContext().getSystemService(Context.WINDOW_SERVICE);
if (winMan != null) {
int orientation = winMan.getDefaultDisplay().getOrientation();
if (orientation == 0) {
// Portrait
setContentView(R.layout.somename_port.xml);
} else if (orientation == 1) {
// Landscape
setContentView(R.layout.somename_land.xml);
}
}
精彩评论