q540817218
q540817218
采纳率0%
2015-04-18 03:25 阅读 2.1k

动态添加的relativelaout,addrule失效

本来我的想法是可以使delImg置于右上角的,但现在是出现在左上角,望各位大神帮个忙,多谢

 ImageView delImg = new ImageView(ReleaseActivity.this);
        delImg.setImageResource(R.drawable.shan);

        RelativeLayout.LayoutParams delParams = new LayoutParams(
                util.DensityUti.dip2px(ReleaseActivity.this, 15),
                util.DensityUti.dip2px(ReleaseActivity.this, 15));
        delParams.alignWithParent = true;
        delParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        delParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);

        relativeLayout.addView(imageView);
        relativeLayout.addView(delImg, delParams);
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • devmiao devmiao 2015-04-18 03:50
  • q540817218 q540817218 2015-04-18 04:05

    我试过加ID,但没用

    点赞 评论 复制链接分享
  • bdmh bdmh 2015-04-18 04:20

    alignWithParent去掉看看

    点赞 评论 复制链接分享

相关推荐