标签:android material-design android-appbarlayout bottomnavigationview android-bottom
我试图实现通常如下所示的新BottomAppBar:
material BottomAppBar作为BottomNavigationView,就像在谷歌主页应用程序中看起来像this.
我的问题是因为我只能用菜单资源填充BottomAppBar,我无法理解如何将我的按钮对齐看起来像BottomNavigationView(但是使用Fab按钮的“cut”)而不是将所有内容对齐到一边BottomAppBar.
如何在这个新的Material BottomAppBar中添加自定义布局?
或者,有没有办法实现BottomNavigationView与Fab按钮的“剪切”(保持酷的默认动画,如新的BottomAppBar)?
解决方法:
解决了
基本上,我没有尝试强制菜单资源到我需要的布局,而是使用了这个解决方案,我只是使用@dglozano建议的“empty”元素将LinearLayout放在BottomAppBar中.
使用?attr / selectableItemBackgroundBorderless我也能够实现与BottomNavigationView非常相似的效果.
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
app:layout_anchorGravity="start"
app:hideOnScroll="true"
app:fabAnimationMode="scale"
app:fabAlignmentMode="center"
app:backgroundTint="@color/colorPrimary">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="5"
android:paddingEnd="16dp">
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_home_white_24dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="@color/secondary_text"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_map_black_24dp"
android:background="?attr/selectableItemBackgroundBorderless"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_people_white_24dp"
android:background="?attr/selectableItemBackgroundBorderless"/>
<ImageButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/ic_account_circle_24dp"
android:background="?attr/selectableItemBackgroundBorderless"/>
</LinearLayout>
</com.google.android.material.bottomappbar.BottomAppBar>
标签:android,material-design,android-appbarlayout,bottomnavigationview,android-bottom 来源: https://codeday.me/bug/20190622/1261488.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。