kotlin xml布局_Android工具栏教程– XML布局和Kotlin

kotlin xml布局

Android Toolbar widget is used to create menus in the apps. We will learn how to create a Toolbar using the XML layout and Kotlin code. We will implement various toolbar properties in an example Android app.

Android工具栏小部件用于在应用程序中创建菜单。 我们将学习如何使用XML布局和Kotlin代码创建工具栏。 我们将在示例Android应用程序中实现各种工具栏属性。

什么是Android工具栏? (What is Android Toolbar?)

Android Toolbar widget is generally found on the top of the screen. The application title, logo, navigation icon, and the menu bar is displayed inside the toolbar.

通常在屏幕顶部找到Android工具栏小部件。 工具栏内显示应用程序标题,徽标,导航图标和菜单栏。

The toolbar is the material design replacement for the old and now deprecated ActionBar.

工具栏是旧的和现在不推荐使用的ActionBar的材质设计替代。

工具栏Gradle依赖关系 (Toolbar Gradle Dependencies)

The toolbar is available with the following dependency.

该工具栏具有以下依赖性。

implementation 'com.android.support:appcompat-v7:27.1.0'

Android Toolbar can be supplied either from the themes or from the layout.

可以从主题或布局中提供Android工具栏。

Android Apps默认工具栏 (Android Apps Default Toolbar)

When you create a new android studio project, you might see that the activity_main.xml doesn’t have any Toolbar defined in the XML. Still, when you see the XML preview, there is a Toolbar with the application name by default at the top.

创建新的android studio项目时,您可能会看到activity_main.xml在XML中没有定义任何工具栏。 仍然,当您看到XML预览时,默认情况下在顶部有一个工具栏,其名称为应用程序名称。

This is because the following style is defined in the styles.xml, which is ultimately attached in the AndroidManifest.xml file.

这是因为在styles.xml中定义了以下样式,该样式最终附加在AndroidManifest.xml文件中。

主题工具栏 (Toolbar from Themes)

DarkActionBar theme adds the Toolbar at the top of the app by default.

默认情况下&

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值