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,然後在編程時求得屏幕的寬高,換算成對應的高,再設置,應該就可以解決了吧。