在我的项目中,我希望在Button
中有两个LinearLayout
元素,但它们之间没有空格。
我已尝试将padding
和margin
设置为0dp
,删除style
并删除ScrollView
,但无效。
我无法找到一种方法来消除按钮之间的空间。
你有什么想法吗?
我的XML是:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The first child in the layout is for the main Activity UI-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_container"
android:orientation="vertical"
>
</LinearLayout>
<!-- Side navigation drawer UI -->
<ScrollView
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="#ffeeeeee"
android:clickable="true"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical" android:padding="0dp" >
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/agenda"
android:drawableLeft="@drawable/agenda_icon"
android:textAllCaps="false"
android:gravity="left|center_vertical"
android:drawablePadding="5dp"
android:layout_margin="0dp"
android:padding="0dp"
/>
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/day"
android:drawableLeft="@drawable/agenda_icon"
android:textAllCaps="false"
android:gravity="left|center_vertical"
android:drawablePadding="5dp"
android:layout_margin="0dp"
android:padding="0dp"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/month"
android:drawableLeft="@drawable/agenda_icon"
android:textAllCaps="false"
android:gravity="left|center_vertical"
android:drawablePadding="5dp"
android:layout_margin="0dp"
android:padding="0dp"
style="?android:attr/borderlessButtonStyle"/>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
</LinearLayout>
</ScrollView>
</android.support.v4.widget.DrawerLayout>
答案 0 :(得分:0)
尝试更改按钮的颜色,因为android原生的按钮的默认界面是中心适合的,使它看起来很酷。
更改按钮的背景颜色以匹配放置它的布局颜色,然后我们将获得按钮的实际尺寸。 在你的情况下
android:background="#000"
答案 1 :(得分:-1)
使用它,因为它不使用它可以通过将宽度设置为硬编码大小并使用默认填充来消除某些问题的样式
<Button
android:id="@+id/btn_overtime"
android:layout_width="310sp"
android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical"
android:text="Overtime"
android:textSize="20sp"
android:textStyle="bold" />