gpt4 book ai didi

android - layout_below 不适用于 CoordinatorLayout android

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:21:32 28 4
gpt4 key购买 nike

这是我的布局文件。

<?xml version="1.0" encoding="utf-8"?>

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ActivityProductList">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@color/primary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>


<ExpandableListView
android:id="@+id/listViewProduct"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="25dip"
android:groupIndicator="@drawable/setting_selector"
android:divider="#FFCC00"
android:dividerHeight="2px"
android:background="@color/windowBackground"
android:layout_below="@+id/toolbar"
android:paddingTop="20dp"
/>

<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:clickable="true"
android:src="@drawable/cart"
android:layout_margin="16dp"
app:elevation="6dp" />

</android.support.design.widget.CoordinatorLayout>

我想垂直设置所有 3 个元素。但它们在当前布局中重叠。

layout_below 在这里似乎不起作用。

如何解决这个问题?

最佳答案

我已经提到了一个布局 fragment ,我猜这就是你想要的。检查 github

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_menu_edit" />

</android.support.design.widget.CoordinatorLayout>

output

无法帮助您使用 FloatingActionButton,它应该是 float 的,哈哈 :)

enter image description here

关于android - layout_below 不适用于 CoordinatorLayout android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34798552/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com