代码之家  ›  专栏  ›  技术社区  ›  Nishant Shah

如何在Android中设置绝对布局的完整图像

  •  0
  • Nishant Shah  · 技术社区  · 15 年前

    我在绝对布局中设置了图像,但它不会在g1上全屏显示,但当我在nexus中运行相同的应用程序时,它工作正常。

    我已经在我的活动类中设置了setContentView(新测试(this))。考试是我的绝对成绩。

    我的代码如下:

    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手机屏幕上获得完整的图像吗?

    1 回复  |  直到 14 年前
        1
  •  0
  •   Nishant Shah    15 年前

    我发现了我还没有设置的问题

    this.addView(mImageView, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));