0

请验证以下相对布局

        RelativeLayout objRLActionBar=new RelativeLayout(this);
        objRLActionBar.setId(2534);
        RelativeLayout.LayoutParams objRLActionBarParams=new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,(int) (screenHeight*layoutHeights[1]));
        objRLActionBarParams.addRule(RelativeLayout.BELOW,objRLTitleBar.getId()); 
        objRLActionBar.setBackgroundColor(Color.parseColor("#2e4862"));

        ImageView objIVActivityIcon = new ImageView(this);
        objRLActionBar.setId(25324);
        RelativeLayout.LayoutParams objIVActivityIconParams=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
        objIVActivityIconParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT,objRLActionBar.getId());
        objIVActivityIcon.setLayoutParams(objIVActivityIconParams);
        objIVActivityIcon.setImageResource(R.drawable.home_def);
        objIVActivityIcon.setPadding(2, 0, 2, 0);
        objRLActionBar.addView(objIVActivityIcon);  

        ImageView objIVSeperator = new ImageView(this);
        objIVSeperator.setId(25342);
        RelativeLayout.LayoutParams objIVSeperatorParams=new RelativeLayout.LayoutParams(1,LayoutParams.FILL_PARENT);
        objIVSeperatorParams.addRule(RelativeLayout.RIGHT_OF,objIVActivityIcon.getId());
        objIVSeperator.setLayoutParams(objIVSeperatorParams);
        objIVSeperator.setImageResource(R.drawable.separator);
        objIVSeperator.setBackgroundColor(Color.parseColor("#1f3449"));  
        objRLActionBar.addView(objIVSeperator);  

        TextView objTVPageName = new TextView(this);
        RelativeLayout.LayoutParams objTVPageNameParams=new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
        objTVPageNameParams.addRule(RelativeLayout.RIGHT_OF,objIVSeperator.getId());
        objTVPageName.setLayoutParams(objTVPageNameParams);
        objTVPageName.setTextColor(Color.WHITE);
        objTVPageName.setTextSize(TypedValue.COMPLEX_UNIT_PX,18+sizeAdjust);
        objTVPageName.setText("House Details"); 
        objTVPageName.setTypeface(null, Typeface.BOLD);
        objTVPageName.setPadding(2, 0, 2, 0);
        objRLActionBar.addView(objTVPageName);  

        objRLBody.addView(objRLActionBar,objRLActionBarParams);

输出如下图所示 在此处输入图像描述

图像与文本重叠,“分隔图像”排在第一位!我需要按 objIVActivityIcon、objIVSeperator、objTVPageName 的顺序排列的组件。上面的代码有什么问题请帮忙...

4

1 回答 1

1
objRLActionBar.setId(25324);

应该

objIVActivityIcon.setId(25324);
于 2012-05-28T09:12:29.537 回答