【问题标题】:Elements below the expandable list - not floating footer可扩展列表下方的元素 - 非浮动页脚
【发布时间】:2014-04-02 07:38:33
【问题描述】:

是否有任何选项可以将元素放在可扩展列表下方,让我解释一下:我已经在列表下方实现了元素,但它们的行为就像页脚 - 浮动在屏幕底部。

但是,如果我将元素放在 xml 中的列表下方,则当任何组展开时,元素都会隐藏。

目前我的布局是这样的

http://shrani.si/f/2s/ba/ga2VKfi/lay2.jpg

但我想在列表末尾这样

http://shrani.si/f/42/4m/2GAcNu6T/lay3.jpg

我现在的布局

<LinearLayout
                android:id="@+id/linearLayoutListExer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:background="#ffffff"
                android:gravity="center_vertical"
                android:orientation="vertical">

                <ExpandableListView
                    android:id="@+id/ExerciseELV"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/linearLayoutStatus"
                    android:layout_weight="1"
                    android:groupIndicator="@null" />

                <LinearLayout
                    android:id="@+id/relativeFooter"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/linearLayoutListExer"

                    android:background="#ffffff"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/textViewBellowExercise"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:padding="10dip"
                        android:text="The following exercises will help you lose body weight"
                        android:textAppearance="?android:attr/textAppearanceSmall"

                        />

                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/textViewBellowExercise">


                        <Button
                            android:id="@+id/buttonFaceit"
                            android:layout_width="0dp"
                            android:layout_height="20dp"
                            android:layout_margin="5dp"
                            android:layout_weight="1"
                            android:background="@color/green"
                            android:text="FaceIT!"
                            android:textColor="@color/white" />

                        <Button
                            android:id="@+id/buttonChallenge"
                            android:layout_width="0dp"
                            android:layout_height="20dp"
                            android:layout_margin="5dp"
                            android:layout_weight="1"
                            android:background="@color/red"
                            android:text="Challenge"
                            android:textColor="@color/white" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>

【问题讨论】:

    标签: java android android-layout android-linearlayout expandablelistview


    【解决方案1】:

    您的以下属性应该更改。 代替 android:layout_below="@id/linearLayoutListExer"

    你应该写 android:layout_below="@id/ExerciseELV"

    对于带有android:id="@+id/relativeFooter"的LinearLayout

    这将使底部布局出现在列表视图下方

    【讨论】:

    • 您的解决方案将我的页脚固定在屏幕底部,但这不是我想要实现的。我希望它在列表下方,当我展开 1 个组项时,我想将页脚推低。目前展开的列表在展开时被推到页脚下方。
    • 您说“此时展开的列表在展开时被推到页脚下面”。一个小的修正。该列表永远不会被推到任何东西之下。列表视图旨在在前面显示最少的项目,但当滚动时,它会显示其他隐藏的项目。您的 group4 内容已超过显示的限制,因此它隐藏在幕后。相同的代码将完美地适用于平板电脑(只要列表内容保持不变)。但对于移动设备,您需要修改布局方法。
    • 抱歉误会,您的解决方案工作正常,但这不是我想要的,我最终使用了“addfooterview”方法,效果很好。
    【解决方案2】:

    我是 android 新手,所以对于我可能提出的任何“愚蠢”问题,我深表歉意。

    我最终使用了 addfooterview 方法,效果很好。

    您需要在自己的xml中分离页脚布局,然后将其膨胀并添加到可展开的列表视图中。

        View footer=inflater.inflate(R.layout.activity_main_footer,null);
        elv.addFooterView(footer); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-02
      • 1970-01-01
      • 2018-02-20
      • 2011-12-09
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多