I have a layout in a layout xml file. I have it with fixed width 110dp. Inside the layout I have a TextView with fixed width 100dp.
When I inflate the view with a LayoutInflater and add it in a LinearLayout, the TextView and it's parent RelativeLayout ignore the set widths and stretch to the text's size. I want the text to wrap in the specified width and take as much height as it requires.
I have tried to force the view's width after inflation ( converting dps to pxs) but still nothing.
Any suggestions?
Layout XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="110dp"
android:layout_height="match_parent"
android:padding="1dp" >
<RelativeLayout
android:layout_centerInParent="true"
android:id="@+id/info_layout"
android:layout_width="108dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:background="@drawable/rounded_corners_grey_3">
<ImageView
android:contentDescription="@string/image"
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"/>
<ImageView
android:contentDescription="@string/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/image_overlay"
android:layout_centerInParent="true"/>
<LinearLayout
android:id="@+id/detailsLayout"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left"
android:layout_margin="3dp"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
>
<TextView
android:id="@+id/name"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="12sp"
android:gravity="center"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"
/>
<TextView
android:id="@+id/details"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:textColor="@color/bethere_green"
android:textSize="12sp"
android:layout_weight="1"
android:ellipsize="none"
android:maxLines="100"
android:scrollHorizontally="false"/>
</LinearLayout>
<ImageView
android:contentDescription="@string/image"
android:id="@+id/noPhotos"
android:layout_width="55dp"
android:layout_height="38dp"
android:src="@drawable/photos_icon"
android:layout_centerInParent="true"/>
</RelativeLayout>
</RelativeLayout>