Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.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 setBackgroundResource在api 16-19中的作用不同_Android_Xml_Background_Android Edittext - Fatal编程技术网

Android setBackgroundResource在api 16-19中的作用不同

Android setBackgroundResource在api 16-19中的作用不同,android,xml,background,android-edittext,Android,Xml,Background,Android Edittext,我正在使用setBackgroundResource(R.drawable.myXmlFile),当我在api 21和以上版本中运行应用程序时,一切正常,但当我在api 16-19中运行应用程序时,它显示出smth不同。 在我的editText on focus中,我试图更改下划线颜色,对于下划线,我使用了一个自定义xml文件: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://sc

我正在使用setBackgroundResource(R.drawable.myXmlFile),当我在api 21和以上版本中运行应用程序时,一切正常,但当我在api 16-19中运行应用程序时,它显示出smth不同。 在我的editText on focus中,我试图更改下划线颜色,对于下划线,我使用了一个自定义xml文件:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
    android:bottom="1dp"
    android:left="-3dp"
    android:right="-3dp"
    android:top="-3dp">
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:thickness="0dp"
    android:shape="rectangle">
    <stroke android:width="1.2dp"
        android:color="#c6c6c6"/>
    <solid android:color="@color/transparent" />
</shape>
</item>
我得到了这个结果:

两个国家之间的比较:

和xml格式的编辑文本:

<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@id/email_input"
        android:hint="Email-i juaj"
        android:textColorHint="@color/fontColor"
        android:textSize="@dimen/font_size"
        android:textColor="@color/fontColor"
        android:paddingTop="@dimen/vertical_padding"
        android:paddingBottom="@dimen/input_bottom_padding"
        android:background="@drawable/border_bottom"
        android:singleLine="true"
        android:layout_marginTop="@dimen/logo_login_bottom_margin"
        android:inputType="textEmailAddress"
        android:imeOptions="actionDone"/>

有谁能帮我解决这个问题吗?提前谢谢

 int version = Build.VERSION.SDK_INT;
尝试获取api版本并放置if循环

  if (version >= 16 && version <= 19) {
    setContentView(R.layout.main);
    }
   else
   {
   setContentView(R.layout.main);
   }

如果(version>=16&&version,但问题是我不知道是什么导致了这种行为。你检查过不同的设备吗?是的,相同…看起来api版本有问题,我的意思是我做得不对(自定义xml方法)我不认为自定义xml会带来任何其他建议可以帮助我的问题,或者我应该尝试其他方法
  if (version >= 16 && version <= 19) {
    setContentView(R.layout.main);
    }
   else
   {
   setContentView(R.layout.main);
   }