我有一个可扩展列表视图,并且为组项设置了背景,但我想调整高度。我已经将高度设置为 xml 文件(50dp),但它不起作用(实际高度不是 50 dp,但它更高),所以我正在考虑以编程方式进行。
这是我的一段代码来解释它
grouplayout_index.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout_index"
android:background="@drawable/bg_capitolo_retina"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_height="50dp" ---------------------//height = 50 dp
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent" >
<ImageView android:id="@+id/freccia_indice" android:src="@drawable/freccia_o"
android:clickable="false"
android:layout_height="28dp"
android:layout_width="28dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:paddingLeft="10dp" />
<TextView android:id="@+id/tvGroup"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dp"
android:paddingLeft="50dp" />
</LinearLayout>
索引.java
public class Index extends ExpandableListActivity {
.....
IndexAdapter mAdapter = new IndexAdapter .....
explistview.setAdapter(mAdapter);
}
索引适配器.java
public class IndexAdapter extends BaseExpandableListAdapter{
....various methods......
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,ViewGroup parent) {
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.grouplayout_index, null);
}
TextView textView = (TextView) convertView.findViewById(R.id.tvGroup);
textView.setTextAppearance(context, R.style.textViewStyleGroup);
textView.setText("textview");
/* I have tried this code but it doesn't works.
LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.LinearLayout_indice);
ll.setLayoutParams(new LinearLayout.LayoutParams(30,50));
*/
}
有人能帮助我吗?