gpt4 book ai didi

java - 部分线性布局隐藏在操作栏下

转载 作者:行者123 更新时间:2023-12-01 19:36:11 25 4
gpt4 key购买 nike

我知道这可能是一个愚蠢的问题,但是作为一个新手,我无法解决它。

所以我想添加带有后退导航按钮的actionBar,并且隐藏了部分LinearLayout。我该如何解决这个问题?

LinearLayout hidden By ActionBar

代码

MainActivity.xml

<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

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


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:fitsSystemWindows="true"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:navigationIcon="@drawable/ic_arrow_back_black_24dp"/>

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



<include layout="@layout/content_main" />



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

内容布局

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

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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main"
>


<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_productname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="15"
app:errorEnabled="true">

<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Product Name"
android:inputType="text"/>
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_price"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorEnabled="true">

<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Price"
android:inputType="numberDecimal|numberSigned"/>
</android.support.design.widget.TextInputLayout>


<!--Add Product-->
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Product"
android:onClick="addProduct"/>

</LinearLayout>

期望

我手动设置 margin-top 来降低 Linearlayout 并显示预期结果。

Expected Result

最佳答案

您需要将布局行为添加到您的内容

<include layout="@layout/content_main"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

关于java - 部分线性布局隐藏在操作栏下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57460711/

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