【问题标题】:Button is Not Appearing When Placing Below The GridView放置在 GridView 下方时,按钮不出现
【发布时间】:2018-03-11 09:35:37
【问题描述】:

我正在使用 Android XML 进行布局,我想在布局底部添加一个按钮,并在其上方添加整个 GridView,但我无法做到! 不知道为什么... 谁能帮帮我?

这是我的 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/btn"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentStart="true"
            android:textAllCaps="false"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <GridView
            android:layout_above="@+id/btn"
            android:fadeScrollbars="true"
            android:id="@+id/PhoneImageGrid"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:columnWidth="90dp"
            android:horizontalSpacing="8dp"
            android:numColumns="auto_fit"
            android:stretchMode="columnWidth"
            android:smoothScrollbar="true"
            android:scrollingCache="false"
            android:animationCache="false"
            android:verticalSpacing="8dp" />

    </RelativeLayout>

【问题讨论】:

  • 完整布局显示 gridView ??
  • 是的,绝对的!
  • android:layout_alignParentEnd="true" android:layout_alignParentStart="true" 尝试从按钮中删除这两行
  • 否则你可以使用按钮 below 并在 Gridview 上删除 above
  • 什么也没发生 :(

标签: android xml button gridview


【解决方案1】:

问题解决了!

我是发布问题的人。我的问题已解决所有这一切都是由于我的标签式活动布局中的 ViewPager 标记中的一个属性。

属性是:

app:layout_behavior="@string/appbar_scrolling_view_behavior"

在标签中:

<android.support.v4.view.ViewPager
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

这导致布局错误,因为布局在屏幕下方结束。 你可以看到 Here

我删除了那个属性,一切都变好了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-01
    • 2021-04-11
    • 1970-01-01
    • 1970-01-01
    • 2021-09-14
    • 1970-01-01
    相关资源
    最近更新 更多