gpt4 book ai didi

android - 结合 DrawerLayout 与 CoordinatorLayout 和 FAB

转载 作者:行者123 更新时间:2023-11-29 00:07:36 25 4
gpt4 key购买 nike

对于我的问题我准备了a simple project at GitHub .

在带有 DrawerLayout 的应用程序中,我试图显示社交网络(Google+、Facebook、Twitter)的登录页面。

登录页面应显示社交网络 Logo (或用户照片 - 如果已登录),然后是水平进度条和一个 FloatingActionButton,最后是底部的一些文本:

app screenshot

不幸的是,我在 ActionBar 区域有一些奇怪的 Artifact - 正如您在上面屏幕截图的右侧所见。

请问为什么会这样,如何解决?

这是我的 activity_main.xml使用 DrawerLayout 和左侧抽屉菜单:

<android.support.v4.widget.DrawerLayout
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">

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

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<FrameLayout
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0"/>

</LinearLayout>

<android.support.design.widget.NavigationView
android:id="@+id/left_drawer"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="#FFF"
app:itemIconTint="@color/drawer_item_text"
app:itemTextColor="@color/drawer_item_text"
app:headerLayout="@layout/header_left"
app:menu="@menu/menu_main"/>

</android.support.v4.widget.DrawerLayout>

这是我的 fragment_google.xml使用 CoordinatorLayoutFAB:

<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">

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

<ImageView
android:id="@+id/photo"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
android:src="@drawable/photo"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />

<CheckBox
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:layout_gravity="center_horizontal"
android:text="Main profile"
/>

<TextView
android:id="@+id/given"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:layout_gravity="center_horizontal"
/>

<TextView
android:id="@+id/place"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:layout_gravity="center_horizontal"
/>

</LinearLayout>

<ProgressBar
android:id="@+id/progress"
android:indeterminate="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchor="@id/photo"
app:layout_anchorGravity="bottom"
style="?android:attr/progressBarStyleHorizontal"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:layout_anchor="@id/photo"
app:layout_anchorGravity="bottom|right|end"
android:src="@drawable/ic_account_plus_white_48dp"
android:elevation="8dp"/>

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

最佳答案

fragment_google.xml 中删除 fitsSystemWindows="true"解决了问题:

app screenshot

关于android - 结合 DrawerLayout 与 CoordinatorLayout 和 FAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32749857/

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