我动态充气下面的XML添加经由膨胀属性相对布局被忽略
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dip"
>
<ImageView
android:id="@+id/grid_img"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:scaleType="fitXY"
android:src="@drawable/nature3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img_name"
android:text=",jfjgf xxfbdg fd dfhs lhl;fsfladsfh; jkhsdl;fshkjfl;fks; l;hflsaf"
android:inputType="textMultiLine"
android:maxLines="2"
android:ellipsize="end"
android:layout_alignBottom="@+id/grid_img"
android:layout_alignRight="@+id/grid_img"
android:layout_alignLeft="@+id/grid_img"
/>
</RelativeLayout>
我经由通货膨胀使用以下代码添加该XML。
RelativeLayout v = (RelativeLayout)inf.inflate(R.layout.ui_three, null);
现在的问题是我在xml中定义的属性被忽略,我得到的android手机上的followin UI。
我得到的TextView与在以XML格式它与图像的底部对齐图像的顶部边缘对齐。
对此问题的任何解决方案。
尝试的FrameLayout代替。 –