如何将笔划应用于android中的按钮特定边

use*_*737 0 android layer-list

如何将笔划应用于按钮的左侧边框和右侧边框?在android中.

我已应用以下代码,但它无法正常工作

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- This is the main color -->
<item>
      <shape>
            <solid android:color="#EEEEEE" />
      </shape>
</item>

<!-- This is the line -->
<item android:right="1dp">
     <shape>
           <solid android:color="#333333" />
     </shape>
</item>

<item android:left="1dp">
    <shape >
        <solid android:color="#333333"/>
    </shape>
</item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

Ale*_*s G 6

你走在正确的轨道上.这样就可以了:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
          <shape>
                <solid android:color="#EEEEEE" />
          </shape>
    </item>

    <!-- This is the line -->
    <item android:right="1dp" android:left="1dp">
         <shape>
               <solid android:color="#333333" />
         </shape>
    </item>

</layer-list>
Run Code Online (Sandbox Code Playgroud)

并将其用作按钮的背景.刚试过它 - 效果很好.