Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.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 - Fatal编程技术网

Android-带边框颜色的选择器?

Android-带边框颜色的选择器?,android,Android,我的单选按钮上有一个seelctor。我需要在每一个上设置一个边界。为什么下面的选择器不应用边框 <selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@integer/short_anim_time"> <item android:drawable="@color/orange" android:state_pres

我的单选按钮上有一个seelctor。我需要在每一个上设置一个边界。为什么下面的选择器不应用边框

<selector xmlns:android="http://schemas.android.com/apk/res/android"
    android:exitFadeDuration="@integer/short_anim_time">

  <item android:drawable="@color/orange"
      android:state_pressed="true"/>

  <item android:drawable="@color/orange"
      android:state_checked="true"/>

  <item android:drawable="@color/white"
      android:state_focused="true"/>

  <item android:drawable="@color/white"/>


  <item>
    <shape>
      <stroke
          android:width="2dp"
          android:color="@color/orange"/>

      <padding
          android:left="@dimen/gap"
          android:top="@dimen/gap"
          android:right="@dimen/gap"
          android:bottom="@dimen/gap"/>
    </shape>
  </item>

</selector>

简单

把你的边框放在它自己的文件里

然后加上

  android:background="@drawable/border"
这就是我如何让它与我的图像视图一起工作的

 <ImageView
        android:id="@+id/iv_icon"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_gravity="center_vertical"
        android:background="@drawable/border"
        android:src="@drawable/foo" />