1. android如何改变listview的每行高度
不知道题主的listview单项布局用的是自定义的还是系统的,如果是系统的那就改变不了,系统自带的布局就是类似simple_item这样的,在使用适配器adapter的时候也是new SimpleAdapter 这样。
如果自定义一个listview , 那在单项布局里就可以直接设置它的高度,layout_height="70dp" 。自定义listview的使用需要自己写一个list_item单项布局和相对应的adapter 。
2. ListView 第一行标题栏的字体大小和行高怎样设置
是要设置ListView.View == View.Details时,设置ColumnHeader的字体大小和行高么?如果不是就不用往下看了:)
粗看了一下,发现字体是可以设置的,但是行高恐怕有点困难。
ListView lv = new ListView();
lv.OwnerDraw = true;
lv.DrawColumnHeader += new (lv_DrawColumnHeader);
...
private void listView1_DrawColumnHeader(object sender, e)
{
// 绘制标准背景
e.DrawBackground();
// 绘制自定义文字
using (Font headerFont = new Font("Tahoma", 10, FontStyle.Bold))
{
e.Graphics.DrawString(e.Header.Text, headerFont,
Brushes.Black, e.Bounds, new StringFormat());
}
return;
}
这里e.Bounds是一个只读属性,表示绘制ColumnHeader时所能操作的矩形范围,这个是Windows产生NM_CUSTOMDRAW是就已经定了的,我对Windows消息机制了解不多,不知道是否有方法来改变这个Bounds的内容,如果能改就可以指定高了。
3. 安卓 调整listview行的宽度
要看你用的是什么适配器给ListView添加的数,不过三种都可以添加自己的布局文件
SimpleAdapter,ArrayAdapter
这两个都一样,就写一个吧
SimpleAdapter adapter = new SimpleAdapter(this, list,R.layout.quick_item,new String[] {"name" },new int[] { R.id.barCodeTextView });
其中"R.layout.quick_item"就是自己写的xml配置文件
BaseAdapter
就在对应的的Adapter中引入自定义布局文件,大概像这样
LayoutInflatermInflater = LayoutInflater.from(mContext);
convertView = mInflater.inflate(R.layout.complex_item, null);
剩下的就是写自己的布局文件,高度,宽度,字体样式都可以根据自己的需要调整,祝你成功吧
4. listview怎样设置每个Item的高度
1.在ListView的布局文件中把属性android:layout_height设置成"wrap_content"
<ListView
android:cacheColorHint="#00000000"
android:textColor="#ff435346"
android:textSize = "20sp"
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout="@+id/textViewCurrentBase"
android:listSelector="#00000000"
android:drawSelectorOnTop="false"/>
2.设置子项xml文件(比如这里把一个item.xml设置成ListView的一行)的各个控件android:layout_height的值。这里80sp+40sp就是你需要的一行的高度了。
item.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:focusable="false"
android:textColor="@drawable/white"
android:id="@+id/ItemTitle"
android:layout_height="80sp"
android:layout_width="fill_parent" />
<TextView android:focusable="false"
android:id="@+id/ItemText"
android:textColor="@drawable/blue"
android:layout_height="40sp"
android:layout_width="wrap_content"
android:layout_below="@+id/ItemTitle" />
<Button
android:id="@+id/ItemButton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
5. ListView怎么设高度在代码中
ListView设高度在代码方法:
1、在ListView的布局文件中把属性android:layout_height设置成"wrap_content"
<ListView
android:cacheColorHint="#00000000"
android:textColor="#ff435346"
android:textSize = "20sp"
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout="@+id/textViewCurrentBase"
android:listSelector="#00000000"
android:drawSelectorOnTop="false"/>
2、设置子项xml文件(比如这里把一个item.xml设置成ListView的一行)的各个控件android:layout_height的值。这里80sp+40sp就是需要的一行的高度。
item.xml如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:focusable="false"
android:textColor="@drawable/white"
android:id="@+id/ItemTitle"
android:layout_height="80sp"
android:layout_width="fill_parent" />
<TextView android:focusable="false"
android:id="@+id/ItemText"
android:textColor="@drawable/blue"
android:layout_height="40sp"
android:layout_width="wrap_content"
android:layout_below="@+id/ItemTitle" />
<Button
android:id="@+id/ItemButton"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
6. 如何设置ListView里Item的行高
定义每一个item的layout的高度。
比如:
在/layout文件中定义row.xml
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="10px"
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
在adapter的getView里面用inflator加载这个layout,就可以达到改变item高度的目的。
7. 请教,如何调整ListView的每一行的行高
这个“abcde”字符串可以是你的listview的内容字串。这样设置的高度正好放下内容,如果你想加高,增加数字就行,
8. 怎么调整Android listview的高度
您好,我来为您解答:
Android主要针对触摸屏,所以默认的行高相当比较到,主要目的是为了使得触摸每一项时能够触摸到。
自定义Adapter,然后在getview方法中设置ListItem的布局,这样可以设置ListView每一个Item的高度~
如果我的回答没能帮助您,请继续追问。
9. Android listview每项自适应高度
item的高度不写死就行了。
android:layout_height="wrap_content"
包括你的textView和item最外层layout,都要这样设置
10. 如何根据屏幕大小调整listview行高
动态设定,按比例来做吧。假定效果图的宽高是480*800,我们的LISTVIEW的高是H,这里可以就有一个比例H/800,然后在编程时求得屏幕的宽高,换算成对应的高,再设置,应该就可以解决了吧。