gpt4 book ai didi

android - 即使添加了 AppBarLayout,工具栏也没有阴影

转载 作者:行者123 更新时间:2023-11-30 05:05:56 25 4
gpt4 key购买 nike

我的工具栏没有任何阴影。大多数解决方案建议我将工具栏包裹在 AppBarLayout 中,当我尝试这样做时,即使那样我也没有得到任何阴影。为什么即使我有 AppBarLayout 也看不到任何阴影,我该如何解决这个问题。

我不想在toolbar下添加view来实现shadow,请问有没有其他稳定的方式实现shadow。

这是我的整个带有工具栏的 xml 布局:

<LinearLayout 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:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways|snap|exitUntilCollapsed">

<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
app:elevation="4dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">

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

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

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_constraintTop_toBottomOf="@id/appbar">

<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
app:layout_scrollFlags="scroll|enterAlways|snap|exitUntilCollapsed">

<TextView
android:id="@+id/textViewProfilePhotoLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="@string/profile_photo_label"
android:textColor="@android:color/black"
android:textSize="16sp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="6dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textViewProfilePhotoLabel">

<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circleImageViewProfilePhoto"
android:layout_width="140dp"
android:layout_height="140dp"
android:src="@color/colorBlack"
app:civ_border_color="#ffffff"
app:civ_border_width="3dp" />

<ImageView
android:id="@+id/imageViewEditProfilePhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:src="@drawable/ic_edit_black_24dp" />

</FrameLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUsersFirstName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/frameLayout">

<android.support.design.widget.TextInputEditText
android:id="@+id/editTextUsersFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_first_name_label"
android:textSize="16sp" />

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

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUsersLastName"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputLayoutUsersFirstName">

<android.support.design.widget.TextInputEditText
android:id="@+id/editTextUsersLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_last_name_label"
android:textSize="16sp" />

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

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutProfileHeadline"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputLayoutUsersLastName">

<EditText
android:id="@+id/editTextProfileHeadline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_tagline_label"
android:textSize="16sp" />

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

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUsersEducation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputLayoutProfileHeadline">

<EditText
android:id="@+id/editTextUsersEducation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_Education_label"
android:textSize="16sp" />

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

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUsersProfession"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputLayoutUsersEducation">

<EditText
android:id="@+id/editTextUsersProfession"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_profession_label"
android:textSize="16sp" />

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

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUsersLocation"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputLayoutUsersProfession">

<EditText
android:id="@+id/editTextUsersLocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_location_label"
android:textSize="16sp" />

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

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUsersBio"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/textInputLayoutUsersLocation">

<EditText
android:id="@+id/editTextUsersBio"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/users_about_me_label"
android:inputType="textAutoCorrect"
android:textSize="16sp" />

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

</android.support.constraint.ConstraintLayout>

</ScrollView>

</LinearLayout>

工具栏中使用的样式:

 <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

为什么我没有得到阴影,我该如何解决这个问题?

提前致谢。

最佳答案

elevationmarginBottom 添加到工具栏,如下所示:

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

关于android - 即使添加了 AppBarLayout,工具栏也没有阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54604456/

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