当我在Android中使用RelativeLayout addview时,视图就是挤压。我怎么能这样做?

时间:2014-11-07 08:31:37

标签: android relativelayout

当我在RelativeLayout中使用addView时:

for (BigClicleTagInfoBean info : bean.tags) {
            BigClicleTagView tagView = null;
            boolean isLeftTag = info.isLeftDirection();
            if(isLeftTag) {
                tagView = new BigClicleTagLeftView(this.getContext(), null);
            } else {
                tagView = new BigClicleTagRightView(this.getContext(), null);
            }
            tagView.setData(info);
            tagView.setTagViewListener(this);
            RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

            int marginLeft = 0;
            int marginRight = 0;
            int marginTop = (int)(info.pos_y * pictureHeight) + 10;

            if(isLeftTag) {
                marginLeft = (int) (info.pos_x * Global.widthPixels);
            } else {
                marginRight = (int) ((1 - info.pos_x) * Global.widthPixels);
            }

            params.setMargins(marginLeft, marginTop, marginRight, 0);
            imageRootRL.addView(tagView, params);
            tagViews.add(tagView);
        }

我希望照片标签显示完好,但在视图边框会挤出。 请帮助我,Thx enter image description here

0 个答案:

没有答案