我動態充氣下面的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代替。 –