android - 自定义按钮栏中按钮之间的分隔符

标签 android button separator buttonbar togglebuttonbar

我已经按照描述制作了自定义按钮栏 here .

现在,我想在第一个和第二个按钮之间以及第二个和第三个按钮之间添加一个分隔符。我的按钮栏定义如下:

<LinearLayout
            android:id="@+id/buttonBar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/buttonbarstyle"
            android:layout_alignParentBottom="true"
            android:orientation="horizontal"
            >
            <ImageButton
                android:id="@+id/buttonBarImageButton1" 
                android:scaleType="centerInside"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/copy"
                android:padding="2dip"
                android:background="@drawable/buttonbar_background_selector"
                android:layout_gravity="center_vertical"
            />              
            <ImageButton 
                android:id="@+id/buttonBarImageButton2"
                android:scaleType="centerInside"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/options"
                android:padding="2dip"
                android:background="@drawable/buttonbar_background_selector"
                android:layout_gravity="center_vertical"
            />              
            <ImageButton
                android:id="@+id/buttonBarImageButton3" 
                android:scaleType="centerInside"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:src="@drawable/media_play"
                android:padding="2dip"
                android:background="@drawable/buttonbar_background_selector"
                android:layout_gravity="center_vertical"
            />              
        </LinearLayout>

这个任务看起来很简单,但是我找不到好的方法来完成它。它应该在每个按钮之间有一个灰色的分隔符,所以它看起来有点像 this。 .

我相信这很容易,请为我指出正确的方向。

最佳答案

将它放在每个按钮之间。

<View android:layout_height="fill_parent"
    android:layout_width="2px"
    android:background="#90909090"/>

应该给你一个细长的灰色垂直条。

关于android - 自定义按钮栏中按钮之间的分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5050498/

相关文章:

java - 为什么在小程序中按下按钮时会错误地按下变量的值?

安卓。隐藏某些 ListView 分隔符

java - java中如何处理具有不同行分隔符的文件?

Android 应用程序无法连接到 Rocket Chat 服务器

html - 一起使用 required 和 readonly 属性

android - 如何滑动执行点击android

url - "+"或 "-"作为 URL 中的分隔符?

android - ActionBar 样式不起作用

android - 小尺寸图片问题

Android工作室错误 "Unsupported Modules Detected: Compilation is not supported for following modules"