Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的水平可画按钮之间没有空间?_Android_Android Layout_Xamarin.android - Fatal编程技术网

Android 为什么我的水平可画按钮之间没有空间?

Android 为什么我的水平可画按钮之间没有空间?,android,android-layout,xamarin.android,Android,Android Layout,Xamarin.android,我的按钮最终看起来像这样: 这是4个切换按钮(好吧,3个半),第二个被选中。我在绘图中设置了填充,但由于某些原因,填充要么被忽略,要么被用于文本的按钮边框。如果我不使用drawable,默认的Android按钮看起来不错,它们之间没有空间 我的布局示例: <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weig

我的按钮最终看起来像这样:

这是4个切换按钮(好吧,3个半),第二个被选中。我在绘图中设置了填充,但由于某些原因,填充要么被忽略,要么被用于文本的按钮边框。如果我不使用drawable,默认的Android按钮看起来不错,它们之间没有空间

我的布局示例:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px">
    <ToggleButton
        android:text="@string/btn_resp_tmp"
        android:id="@+id/resp1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="@drawable/CustomSelector"
        android:enabled="true" />
    <ToggleButton
    (...)


按以下代码设置形状填充时:

<padding
      android:left="10dp"
      android:right="10dp"
      android:top="10dp"
      android:bottom="10dp" />

这意味着红线是10dp

但在选择器中,您无法定义形状边距。因此,作为一种解决方法,您可以设置切换按钮边距:

<ToggleButton
        ......
        android:layout_marginRight="5dp"
         ..... />

您节省了时间,谢谢。在布局中使用边距是我的想法,但我认为一定是我做错了什么,因为默认的Android按钮有“内置”的边距。不再寻找答案是一种解脱。
<ToggleButton
        ......
        android:layout_marginRight="5dp"
         ..... />