gpt4 book ai didi

android - 将 LinearLayout 定位在 Toolbar 下方

转载 作者:行者123 更新时间:2023-12-05 00:21:37 25 4
gpt4 key购买 nike

我有以下布局:

<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<import type="android.view.View" />

<variable
name="imagelimit"
type="int" />

</data>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="@bool/fitsSystemWindows">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_height"
android:background="@color/colorPrimary" />

<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordlt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginTop="@dimen/status_bar_height"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<include
android:id="@+id/incltoolbar"
layout="@layout/toolbar" />

<LinearLayout
android:id="@+id/baseLlt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="155dp"
android:gravity="center"
android:textSize="16sp"
android:textStyle="bold"
android:text="@string/no_pet_images_yet"
android:visibility="@{imagelimit == 0 ? View.VISIBLE : View.GONE}" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:gravity="center"
android:textSize="15sp"
android:text="@string/pet_images_limit"
android:visibility="@{imagelimit == 0 ? View.VISIBLE : View.GONE}" />

<GridView
android:id="@+id/imageGrdv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:numColumns="2"
android:visibility="@{imagelimit != 0 ? View.VISIBLE : View.GONE}" />

</LinearLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/addImageFlbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add"
android:visibility="@{imagelimit != 1 ? View.VISIBLE : View.GONE}"
app:layout_anchorGravity="bottom|right|end" />

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

</FrameLayout>

</layout>

我想在工具栏下方显示 LinearLayout (@+id/baseLlt) 而不向其添加边距顶部属性(工具栏高度对于所有类型的设备都不相同)。是否有适当的解决方案来实现这一目标?

最佳答案

你可以简单地包装你的 ToolbarLinearLayout在垂直 LinearLayout ,像这样:

<FrameLayout 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="@bool/fitsSystemWindows">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="@dimen/status_bar_height"
android:background="@color/colorPrimary" />

<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordlt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/status_bar_height"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

<include
android:id="@+id/incltoolbar"
layout="@layout/toolbar" />

<LinearLayout
android:id="@+id/baseLlt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="155dp"
android:text="@string/no_pet_images_yet"
android:textSize="16sp"
android:textStyle="bold"
android:visibility="@{imagelimit == 0 ? View.VISIBLE : View.GONE}" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="20dp"
android:text="@string/pet_images_limit"
android:textSize="15sp"
android:visibility="@{imagelimit == 0 ? View.VISIBLE : View.GONE}" />

<GridView
android:id="@+id/imageGrdv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:horizontalSpacing="0dp"
android:numColumns="2"
android:verticalSpacing="0dp"
android:visibility="@{imagelimit != 0 ? View.VISIBLE : View.GONE}" />

</LinearLayout>
</LinearLayout>

<android.support.design.widget.FloatingActionButton
android:id="@+id/addImageFlbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="@drawable/ic_add"
android:visibility="@{imagelimit != 1 ? View.VISIBLE : View.GONE}"
app:layout_anchorGravity="bottom|right|end" />

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

</FrameLayout>

关于android - 将 LinearLayout 定位在 Toolbar 下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44839628/

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