【问题标题】:listview items not filled the whole area(Expandable list view)列表视图项目未填满整个区域(可扩展列表视图)
【发布时间】:2014-09-07 19:50:18
【问题描述】:

我指的是 this 实现 3 级可扩展列表。代码工作正常。但我的问题是,子元素中的项目没有填满整个区域。因此,我无法通过单击展开下一个子元素。(我必须单击出现子元素文本的确切区​​域)

谁能指点我,问题出在哪里?

我也将我的 xml 视图编辑为android:layout_width="fill_parent"

但是没有用.. 请帮助我。 谢谢。

编辑

这里是所有布局 XML 代码。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff5b5b"
android:orientation="vertical" >

<TextView
    android:id="@+id/itemRootTitle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    tools:ignore="HardcodedText" />

  </LinearLayout>

家长

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#40e0d0"
android:orientation="vertical" >

<TextView
    android:id="@+id/itemParentTitle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    tools:ignore="HardcodedText" />

     </LinearLayout>

儿童

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#839096"
android:orientation="vertical" >

<TextView
    android:id="@+id/itemChildTitle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    tools:ignore="HardcodedText" />

 </LinearLayout>

主要 XML 布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<ExpandableListView
    android:id="@+id/expList"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:choiceMode="singleChoice"
     >

</ExpandableListView>

  </RelativeLayout>

【问题讨论】:

  • 你能显示你的行布局吗
  • 显示 R.layout.item_child 的代码
  • 在你的行布局文件中设置 android:layout_width="fill_parent"..
  • @DigveshPatel 我现在在我的问题中提到了它们..
  • @Erick 是的...但感谢您宝贵的时间:)

标签: android listview expandablelistview


【解决方案1】:

我在使用微调器时也遇到了这个问题 我是这样解决的

子 xml。

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#839096"
android:orientation="vertical" >

<TextView
    android:id="@+id/itemChildTitle"
    android:layout_width="match_parent" <== and this
    android:minWidth="500dp"  <=== add this
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge"
    tools:ignore="HardcodedText" />

 </LinearLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-28
    相关资源
    最近更新 更多