gpt4 book ai didi

android - Action 条不消失

转载 作者:搜寻专家 更新时间:2023-11-01 09:19:36 25 4
gpt4 key购买 nike

我刚刚开始学习 Android 编码,我想禁用位于主要 Activity 上边缘的默认操作栏,并将其替换为可自定义的工具栏。我查看了此网页并按照说明进行操作:https://developer.android.com/training/appbar/setting-up

不幸的是,操作栏并没有消失。显示工具栏时,操作栏仍保留在 Activity 布局的上边缘。

我在 list 和布局文件中都插入了这段代码:

申请 android:theme="@style/Theme.AppCompat.Light.NoActionBar"

如果我在布局文件中插入它,新创建的工具栏会变成透明的,这不是我想要的。我想让默认操作栏消失。如果我将它插入 list 中,什么也不会发生

这是布局文件的部分xml代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:theme="@style/Theme.AppCompat.Light.NoActionBar"

tools:context=".MainActivity">

<android.support.v7.widget.Toolbar
android:id="@+id/my_toolbar"
android:layout_width="331dp"
android:layout_height="62dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.018"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

如果有人能帮我解决这个问题,我会很高兴。提前致谢!!!

最佳答案

在你的styles.xml文件:

改变:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

现在您可以随心所欲地使用工具栏

希望这能奏效...干杯!!!

关于android - Action 条不消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57441582/

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