英文:
Android: Change App bar height of one fragment and delete text
问题
我想要更改特定的fragment_layout
的应用程序栏。我想将高度从默认值"56dp"
更改为"96dp"
以适应我的公司徽标。我还想删除默认文本。
不幸的是,我在互联网上没有找到任何关于此的参考,或者可能是我忽略了它。
我将非常感谢任何帮助。
编辑:我知道如何更改整个应用程序的应用程序栏高度,但这不是这里的问题
英文:
I would like to change the app bar of a certain fragment_layout
. I would like to change the height from the default value "56dp" to "96dp"
to fit my company logo. I also want to delete the default text.
Unfortunately, I have not found any reference to this on the Internet or have overlooked it.
I would be glad about any help.
EDIT: I know how to change the app bar height of the entire app, but that is not the question here
答案1
得分: 1
以下是您要翻译的内容:
"Let's have a look to how the toolbar is declared inside a layout.
<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>
Pay attention to attributes android:minHeight
and android:layout_height="wrap_content"
.
MinHeight attribute references itself to ?attr/actionBarSize
which has a value of 56dp.
1) To change the toolbar height change android:layout_height
.
Example: android:layout_height="300dp"
2) To delete the default text, you will have to find the toolbar from code and use a method. Add this to the class where you setContentView
of the layout containing the toolbar.
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
Result:
英文:
Let's have a look to how the toolbar is declared inside a layout.
<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>
Pay attention to attributes android:minHeight
and android:layout_height="wrap_content
.
MinHeight attribute references itself to ?attr/actionBarSize
which has a value of 56dp.
1) To change the toolbar height change android:layout_height
.
Example: android:layout_height="300dp"
2) To delete the default text, you will have to find the toolbar from code and use a method. Add this to the class where you setContentView
of the layout containing the toolbar.
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
Result:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论