背景: 我的工作程序包含有5行11列有一个重写的适配器,用于显示一个GridView。它为我的大显示屏平板电脑需求的伟大工程。
BACKGROUND: My working app contains a GridView with 5 rows of 11 columns with an overridden adapter for display. It works great for my needs with a large display tablet.
移植到一个小规模的智能手机后,我认识到,网格是不可用的,由于其体积小。而不是实行横向我已经决定要使用变焦功能。
After porting to a small scale smartphone, I realize that the grid is unusable, due to its small size. Rather than implement landscape orientation I've decided to use a zoom function.
问: 什么是实现以下两个基本功能的最佳方式:变焦(允许放大100至400%)和Scroll(上/下/左/右)
QUESTION: What is the best way to implement the following 2 basic functions: Zoom (allow zoom between 100 and 400%) and Scroll (up/down/right/left)
我的解决方案是创建一个布局重新计算程序,改变列#及其大小
My solution was to create a layout recalculation routine, changing the # of columns and their sizes
有可能是一个更好的办法,但没有答复,这是一个工作快速和肮脏的黑客
There may be a better way, but with no replies, this is a quick and dirty hack that worked
public void gvlpRecalc() {
m_gv.setNumColumns(m_Columns);
if ((btnWidth = (int) (m_gv.getWidth() / m_Columns + .5)) == 0) {
Display display = ((Activity) m_Context).getWindowManager().getDefaultDisplay();
btnWidth = (int) (display.getWidth() / m_Columns + .5);
switch (m_Columns) {
case 8:
btnHeight = (int) (btnWidth * .9);
break;
case 10:
btnHeight = (int) (btnWidth * 1.2);
break;
default:
btnHeight = btnWidth;
}
} else
switch (m_Columns) {
case 8:
btnHeight = (int) (btnWidth * .9);
break;
case 10:
btnHeight = (int) (btnWidth * 1.2);
break;
case 11:
btnHeight = btnWidth;
break;
default:
btnHeight = (int) (m_gv.getHeight() / 2.2);
}
gvlp = new GridView.LayoutParams(btnWidth, btnHeight);
}
上一篇:如何在Android上运行gif文件?文件、如何在、Android、gif
下一篇:保持对苹果的VerifyReceipt得到21002“显示java.lang.NullPointerException”苹果、VerifyReceipt、NullPointerException、la