我是android新手。 用listview遇到一个问题,就是listview选中一行的时候,只有有字的地方高亮。挺难看。如图:
如何选中一整行呢?高手快来。
如何选中一整行呢?高手快来。
解决方案 »
- 关于Android中地图开发的路线及路标问题
- 弹出窗口的程序中showAsDropDown,showAtLocation方法的参数分别什么意思?求解!
- Adapter是否异步加载数据
- android surfaceview使slidingdrawer布局显示不完整?
- android 虚拟机 cpu50%
- Android下如何读写SDIO接口?
- UI布局通过代码生成吗
- 请教一下获取FTP图片的高效方法
- 求助大神,Android开发 多线程问题·····困在这里一天了·····
- 关于按钮相应事件问题
- android 修改系统默认时区以及显示语言
- ScrollerView下的EditText滚动问题
那我再试. 我是用了 str + " " ;的形式避过了这个问题.
android:layout_height="fill_parent"
android:layout_width="fill_parent"
我个人认为你应该是把
android:layout_width="wrap_content"
设置成这样了。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:id="@+id/ItemTextView" android:layout_width="fill_parent" android:layout_height="fill_parent"></TextView>
</LinearLayout>
还不行啊.我都设了. 莫非是什么灵异事件?
不过同样谢谢各位, 正确的代码贴上来 同时再问,难道我这是歪解?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="50px">
<ImageView android:id="@+id/ImageViewLI" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
<TextView android:id="@+id/ItemTextView" android:layout_height="fill_parent" android:layout_width="600px"></TextView>
</LinearLayout>
谢谢,答复 . 我用了weight试了一下. 我发现, 如果是这样:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="50px" android:layout_width="fill_parent">
<ImageView android:id="@+id/ImageViewLI" android:layout_height="wrap_content" android:layout_width="fill_parent"></ImageView>
<TextView android:id="@+id/ItemTextView" android:layout_height="fill_parent" android:layout_weight="5" android:layout_width="fill_parent"></TextView>
</LinearLayout>显示效果和原来的那个相同 . 也就是说虽然LinearLayout 设置了 fill_parent的宽度,但显示的时候还是那么宽. Weight的用法我学习了一下,很好. 但确实和这个无关. 我现在就总结一下,解决这个问题的几个关键点. 1 我首先设置了listitem对应的layout,讲这个layout中的linearlayout,和textview都设置成了fill_parent
但这样还是不行. 2 我又到包含listview的layout中,讲listview的width设置成了fill_parent ,还是不行. 3 我又在包含listview的layout中,讲listview的上层,linearlayout的width设置成fill_parent ,OK了!楼上朋友说的weight指的是相对长度,也就相当于html中的20%之类. 比如左右两个空间比例是1和5 ,那就设置weight为 1 和 5 , 就能实现. 总体来说,要想使得选中高亮覆盖整个行,你需要从最顶层到这个listview,所有的width都要设置成fill_parent才行 . 好了给分.
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1"
> <LinearLayout android:orientation="horizontal"
android:layout_height="24pt"
android:layout_width="fill_parent" android:weightSum="1">"
<ImageView android:id="@+id/msgimg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="7px"
android:layout_marginLeft="9pt"
android:layout_gravity="center_vertical"/>
<TextView android:id="@+id/title"
android:layout_width="100pt"
android:layout_height="wrap_content"
android:textSize="22px"
android:textColor="#000000"
android:layout_gravity="center_vertical"
android:layout_marginLeft="3pt"
/> </LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="50px" android:layout_width="200pt">
<ImageView android:id="@+id/ImageViewLI" android:layout_height="wrap_content" android:layout_width="fill_parent"></ImageView>
<TextView android:id="@+id/ItemTextView" android:layout_height="fill_parent" android:layout_weight="5" android:layout_width="fill_parent"></TextView>
</LinearLayout>