【发布时间】:2014-02-13 07:50:30
【问题描述】:
我的问题的标题几乎概括了我想问的问题,所以在描述中我将详细描述我的问题。
所以我有一个 ExpandableListView,它以黑色打印在屏幕上,里面有白色文本。当我按下列表时,它会被消耗,我可以选择其中的详细信息。它看起来像这样:
|--------------------------|
|black color |
| Title text(in white) |
| |
|__________________________|
| Item 1 (black text with white background)
| Item 2 |
| Item N... |
所以我的问题是如何更改“文本标题”内部的背景颜色并限制标题中显示的符号数量?
这是我的 XML 文件:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="228dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f4f4f4"
android:orientation="vertical" >
<ExpandableListView
android:id="@+id/lvExp"
android:layout_width="match_parent"
android:layout_height="485dp" >
</ExpandableListView>
</LinearLayout>
</ScrollView>
项目。 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="55dip"
android:orientation="vertical" >
<TextView
android:id="@+id/lblListItem"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17dip"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingLeft="?android:attr/expandableListPreferredChildPaddingLeft" />
</LinearLayout>
组.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp"
android:background="#000000">
<TextView
android:id="@+id/lblListHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="?android:attr/expandableListPreferredItemPaddingLeft"
android:textSize="17dp"
android:textColor="#f4f4f4"
android:background="#323232"/>//this only changes some part of the background just around the text ONLY
</LinearLayout>
【问题讨论】:
-
“限制标题中显示的符号数量”是什么意思?
-
例如如果标题是“我爱吃肉”在屏幕上会出现“我爱吃...”
-
为 textview 添加 android:singleLine="true" 属性
-
要更改背景颜色,为布局设置背景颜色,而不是为 textview 设置背景颜色
-
很好,这确实起到了改变背景颜色的作用!谢谢!但是符号的数量还是一样的:/
标签: android xml background expandablelistview