0

当我加载图像时图像占用空间我不明白为什么在第一个图像显示后占用空间其他图像正常显示你可以看到我的活动 java 类具有 imagedisplay 方法我也在这里加载图像在这个图像是采取第一张图片前后的空格

在此处输入图像描述

我的活动.java

public void imagedisplay()
{
    itable = (TableLayout)findViewById(R.id.itable);

    String chekplace=null;

    Log.e("MyList Size", "Counted--->"+mylist.size());

    int size=mylist.size();
    s:
       for(int j=0;j<mylist.size();j++)
        {

            trstate = new TableRow(this);
            trstate.setGravity(Gravity.CENTER_HORIZONTAL);


            tstate = new TextView(this);
            tstate.setGravity(Gravity.CENTER);

            String tempstate = mylist.get(j).get(KEY_PLACENAME).intern().toString();
            tstate.setText(tempstate);

            trstate.addView(tstate);
            itable.addView(trstate);

            chekplacename=mylist.get(j).get(KEY_PLACENAME).intern().toString();


            int counter=1;
            String nextplace=chekplacename;
            chekplace=nextplace;
            m:
                while(nextplace==chekplace)
            {
                     trimage = new TableRow(this);
             trimage.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
              for (int m = 1; m <= 4; m++)
           {                      
                       chekplace=mylist.get(j).get(KEY_PLACENAME).intern().toString();

                if(nextplace==chekplace)     
                {
                          iimage = new ImageView(this);
              iimage.setPadding(2,2,2,2);
                          BitmapFactory.Options bmOptions;
              bmOptions = new BitmapFactory.Options();
             bmOptions.inSampleSize = 4;
                String loadimageurl=mylist.get(j).get(KEY_PHOTOURL).intern().toString();
                counter++
                        bm = LoadImage(loadimageurl, bmOptions);

                int height=bm.getWidth();
                int width=bm.getHeight();  

               Log.e("newheight","Before--->" +height);
           Log.e("new width","Before--->"+width);
               bm=resize(bm, bm.getHeight(), bm.getWidth());
               height=bm.getWidth();
               width=bm.getHeight(); 

                    iimage.setLayoutParams(new TableRow.LayoutParams( height, width));
        iimage.setImageBitmap(bm);
                trimage.addView(iimage); 
                     }

           }
            itable.addView(trimage);    

        }    
     }       
4

0 回答 0