android - 在linearLayout(android kotlin)的工具栏顶部放置一个按钮
问题描述
我想在linearLayout中的工具栏顶部放置一个按钮,就像在照片中一样。有没有办法做到这一点?
这是我的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/constr"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SettingsAct.SettingsActiv">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorAccent" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
解决方案
这边走:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/constr"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".SettingsAct.SettingsActiv">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbarSettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorAccent" >
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</android.support.v7.widget.Toolbar>
</LinearLayout>
推荐阅读
- reactjs - 创建一组条目时将唯一变量传递给 onClick 函数
- amazon-web-services - 为什么我需要通过预签名 url 上传到 s3 的存储桶策略?
- c# - 高 DPI 缩放 WinForms 面板控件不缩放
- rest - 软件开发接口术语之间的区别:API、Web API、REST API、Web 服务、SOAP 服务
- mysql - 如何在 cpanel 中设置连接 mysql 数据库的节点 js 服务器
- python - 有效年份范围的正则表达式
- math - 如何在ckeditor中将路径写入本地MathJax库?
- javascript - 为什么状态为空?
- android - 使用 Retrofit + RxJava 的 Android Twitter API 状态/过滤器:永远不会点击 onNext 或 onError
- reactjs - 如何重新渲染功能组件?