[英]Remove padding from bottom toolbar completely?
i am building a bottom Toolbar
for my app. 我正在为我的应用程序构建一个底部Toolbar
。 It should look exactly like this example from the Google design: 它看起来应该与Google设计中的示例完全相同:
My problem is that i cant get the small "P" image on the left of the bottom Toolbar to fill the entire Toolbar. 我的问题是我无法在底部工具栏的左侧获得小的“ P”图像来填充整个工具栏。 There is always a small padding. 总是有一个小的填充。 Also the image buttons for skip and pause dont center nicely in the toolbar when i change the Toolbar size manually to be slimmer. 当我手动更改工具栏的尺寸使其更苗条时,用于跳过和暂停的图像按钮也不会很好地居中。 Take a look at my current Toolbar: 看一下我当前的工具栏:
Check out my layout file for the Toolbar: 查看我的工具栏布局文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_bottom"
android:layout_width="match_parent"
android:layout_height="24dp"
android:background="@android:color/white"
android:minHeight="24dp"
android:layout_alignParentBottom="true"
app:elevation="4dp"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetRight="0dp"
android:padding="0dp"
android:layout_margin="0dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_margin="0dp"
android:padding="0dp"
android:gravity="center_vertical">
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:src="@mipmap/ic_launcher"/>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<ImageButton
android:id="@+id/btn_skip_previous"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_skip_previous_black"
style="@style/Widget.AppCompat.ActionButton" />
<ImageButton
android:id="@+id/btn_playpause"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_toRightOf="@id/btn_skip_previous"
android:src="@drawable/ic_pause_black"
style="@style/Widget.AppCompat.ActionButton" />
<ImageButton
android:id="@+id/btn_skip_next"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_toRightOf="@id/btn_playpause"
android:src="@drawable/ic_skip_next_black"
style="@style/Widget.AppCompat.ActionButton" />
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.Toolbar>
Please help me, how can i get the bottom Toolbar like in the first picture?? 请帮助我,如何获得第一张图片所示的底部工具栏?
EDIT: Here is what i got with Daniel Lews tips. 编辑:这就是我与丹尼尔·勒斯的秘诀。 The symbols are arranged better now, but there is still a lot of padding all over the place: 这些符号现在排列得更好,但是到处仍然有很多填充:
You have android:minHeight="24dp"
set on the Toolbar
, and thus it's guaranteed to be at least 24dp tall. 您在Toolbar
上设置了android:minHeight="24dp"
,因此保证至少高24dp。 Try removing android:minHeight
. 尝试删除android:minHeight
。
(Most of the other attributes you've set in an attempt to fix it could also probably be removed.) (您为修复此问题而设置的其他大多数属性也可能会删除。)
As for centering the controls - there's no layout attributes telling them to be centered right now! 至于控件的居中-没有布局属性告诉它们现在居中! There are a variety of ways to solve this problem: 有多种方法可以解决此问题:
RelativeLayout
to have a height of wrap_content
, then use the gravity center_vertical
. 将父级RelativeLayout
设置为wrap_content
的高度,然后使用重力center_vertical
。 android:layout_centerVertical="true"
. 将每个孩子设置为以android:layout_centerVertical="true"
为中心。 match_parent
and then use android:gravity
to set where the content inside each child should go. 将每个孩子的身高设置为match_parent
,然后使用android:gravity
设置每个孩子内的内容应放置的位置。 ...And I'm sure there are more ways. ...而且我相信还有更多方法。
You might want to change the RelativeLayout
to a LinearLayout
with weights so that you can have all the buttons be correctly spaced in a horizontal manner. 您可能需要将RelativeLayout
更改为带有权重的LinearLayout
,以便可以将所有按钮正确地以水平方式隔开。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.