android相对布局下面没有以编程方式工作

时间:2015-03-11 14:09:55

标签: android android-imageview android-view android-relativelayout

我尝试以编程方式创建相对布局。我编写了一些代码并创建了布局,我使用自己的自定义视图为我的布局充气。我无法控制我以编程方式创建的布局 addRulle无法正常编译。 这是我的xml代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<EditText
    android:id="@+id/Bisoutflowproducttxt2"
    android:layout_width="match_parent"
    android:layout_height="40dp"
    android:layout_marginTop="15dp"
    android:background="@drawable/credomoreinfo"
    android:gravity="left|center_vertical"
    android:hint="moreinfo"
    android:paddingLeft="15dp"
    android:textColor="#363636"
    android:textSize="17dp" />

<ImageView
    android:id="@+id/addmore"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/Bisoutflowproducttxt2"
    android:layout_below="@+id/Bisoutflowproducttxt2"
    android:layout_marginTop="30dp"
    android:background="@drawable/add_icon" />

这是我的java代码

view = mInflater.inflate(R.layout.inflatelayout, null, false);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.BELOW, R.id.addmore);
view.setLayoutParams(lp);

customlayout.addView(view);

正如我所说的添加新布局但我无法控制我的新布局。我想我的布局应该是我的imageview 如果有人知道解决方案,请帮助我 感谢

0 个答案:

没有答案