标签:android-toolbar android-layout toolbar android
工具栏的顶部有3个按钮(3个图像按钮),
下面的2个按钮,搜索框(图像按钮)和镜头(图像按钮)
我在顶部放置了3个按钮,但无法在正确的位置添加搜索框和镜头按钮
我正在使用导航抽屉活动.活动名称为“家”
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true"
tools:context="com.example.cortana.shopv3.HomeActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:weightSum="1">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="@android:drawable/ic_menu_sort_by_size"
android:layout_marginLeft="100sp"
android:background="@null"
android:adjustViewBounds="true"
android:cropToPadding="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="@android:drawable/btn_plus"
android:layout_marginLeft="15sp"
android:background="@null"
android:adjustViewBounds="true"
android:cropToPadding="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/ic_menu_save"
android:id="@+id/savebtn"
android:background="@drawable/refreshgreen"
android:adjustViewBounds="true"
android:layout_marginLeft="15sp"
android:layout_alignParentTop="true"
android:layout_marginBottom="15sp"
android:cropToPadding="true" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
解决方法:
试试这个让你的工具栏像这样
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="100sp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="true"
app:srcCompat="@android:drawable/ic_menu_sort_by_size" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15sp"
android:adjustViewBounds="true"
android:background="@null"
android:cropToPadding="true"
app:srcCompat="@android:drawable/btn_plus" />
<ImageButton
android:id="@+id/savebtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="15sp"
android:layout_marginLeft="15sp"
android:adjustViewBounds="true"
android:background="@drawable/ic_down"
android:cropToPadding="true"
app:srcCompat="@android:drawable/ic_menu_save" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
标签:android-toolbar,android-layout,toolbar,android 来源: https://codeday.me/bug/20191025/1931638.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。