0

在我的代码中,我有一个按钮,并且我已经成功地向它们添加了选择器和形状属性。但是没有显示边框线,并且仅在按下按钮时才会出现卷边。请帮我解决。

activity_sam.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/sam"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/sam_back"
    tools:context=".SamActivity" >

    <Button
        android:id="@+id/button1"
        android:layout_width="250dp"
        android:layout_height="75dp"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="39dp"
        android:background="@drawable/buttonsel" />

</RelativeLayout>

按钮.xml

    <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item    android:state_pressed="true">
    <shape  >
    <solid android:color="#f27d0f"/>
    <corners  android:radius="7dp"/>
    </shape> 
  </item>

  <item    android:state_focused="true">
    <shape  >
    <solid android:color="#f27d0f"/>
    <corners android:radius="7dp"/>
    </shape> 
  </item>

  <item   android:state_focused="false"
          android:state_pressed="false"
          android:drawable="@drawable/sam_logo" >
    <shape  >
    <strok  android:width="1dp"
            android:color="#171717" />
    <corners  android:radius="7dp"/>
    </shape> 
  </item>

</selector>
4

1 回答 1

0

删除线

<item
         android:state_focused="false"
        android:state_pressed="false"
         android:drawable="@drawable/sam_logo" > // Remove this line
        <shape  >
    <stroke
            android:width="1dp"
            android:color="#171717" />
    <corners 
    android:radius="7dp"/>
    </shape> 
    </item>
于 2013-10-30T12:55:33.337 回答