在Android中定义了一个MyTextView extends View,在Activity中使用的时候,高度设置为wrapcontent可以正常显示,但是在Listview中高度设置为wrapcontent就会变成0,显示不出来我的View,需要固定高度为100dip等,这中问题可以解决吗.
你的item的高宽怎么设置的
贴下整个Item的代码
我也遇到一样的问题,就是在listview的item布局文件里面,我自己自定义了一个view,高度如果不指定就显示不出来,其实我就是想做个时间轴的效果,下面是我的代码,请问知道解决方案的可以和我说一下,谢谢
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/customer_rel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:paddingRight="15dp">
<View
android:id="@+id/customer_text_view"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:background="#A6A6A6"/>
<ImageView
android:id="@+id/customer_text_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="19dp"
android:layout_marginTop="27dp"
android:src="@mipmap/confirmcase_note_mail" />
<RelativeLayout
android:id="@+id/customer_text_relative"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/customer_text_image">
<LinearLayout
android:id="@+id/customer_text_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="23dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:src="@mipmap/confirmcase_note_avatar" />
<TextView
android:id="@+id/customer_text_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:singleLine="true"
android:text="张三:"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/customer_text_linear"
android:orientation="vertical">
<TextView
android:id="@+id/customer_text_content"
android:layout_width="225dp"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:text="ceceddddddddsdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
android:textSize="18sp" />
<TextView
android:id="@+id/customer_text_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="45dp"
android:text="05/12 14:22:24"
android:textSize="18sp" />
</LinearLayout>
</RelativeLayout>