【发布时间】:2010-07-28 09:07:44
【问题描述】:
我在 AbsoluteLayout 中设置了图像,但它不会在 G1 上全屏显示,但是当我在 Nexus 中运行相同的应用程序时,它可以正常工作。
我在我的活动类中设置了 setContentView(new Test(this))。测试是我的 AbsoluteLayout 类。
我的代码如下:
public class Test extends AbsoluteLayout {public Test(Context context) {
super(context);
final RelativeLayout rl = new RelativeLayout(context);
final android.widget.RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
rl.setLayoutParams(params);
this.addView(rl, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
ImageView mImageView = new ImageView(context);mImageView.setImageBitmap(((DataStorage)context.getApplicationContext()).getImage());
this.addView(mImageView); }}
谁能告诉我为什么我没有在 G1 手机屏幕上获得完整图像?
【问题讨论】:
-
不要使用 AbsoluteLayout。曾经。另外,为什么要在 AbsoluteLayout 中创建一个空的 RelativeLayout?您可能应该改用 XML 定义布局。
-
是的,你是对的,但在我的应用程序中,我想在我的活动上画线和矩形。在java中你只能扩展一个类。我想访问 AbsoluteLayout 的 onScrollChanged() 事件的方法。在绝对布局中,您可以在屏幕上绘画。