1

我想更改某个fragment_layout. 我想更改默认值的高度"56dp" to "96dp"以适合我的公司徽标。我还想删除默认文本。

不幸的是,我在 Internet 上没有找到任何对此的参考或忽略了它。

我会很高兴有任何帮助。

编辑:我知道如何更改整个应用程序的应用程序栏高度,但这不是这里的问题:)

4

1 回答 1

1

让我们看看工具栏是如何在布局中声明的。

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:minHeight="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:titleTextColor="@color/colorTextMain"
        android:background="@color/colorPrimary">

    </androidx.appcompat.widget.Toolbar>

注意属性android:minHeightandroid:layout_height="wrap_content

MinHeight 属性引用自身,?attr/actionBarSize其值为 56dp。

1)改变工具栏高度变化android:layout_height

例子:android:layout_height="300dp"

2)要删除默认文本,您必须从代码中找到工具栏并使用一种方法。将此添加到setContentView包含工具栏的布局的类中。

Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);

结果:

在此处输入图像描述

于 2020-08-14T09:27:54.537 回答