在我的应用程序中,我使用在support库23.2中添加的矢量可绘制对象来显示矢量图标,它运作得非常完美。但是,当我将矢量图标设置为EditText的drawableLeft时,在早期的Android版本中不起作用。在运行时,会出现ResourceNotFound异常。
Caused by: android.content.res.Resources$NotFoundException: File
res/drawable/layer_ic_user.xml from drawable resource ID #0x7f0200b3
这是我的gradle配置:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
generatedDensities = []
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/res/assets/'] } }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.3.0'
}
apply plugin: 'com.google.gms.google-services'
编辑文本框:
<EditText
android:id="@+id/et_username_or_email"
android:layout_width="@dimen/edit_text_width"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/layer_list_ic_user"
android:textColorHint="@color/ColorBlackPrimary"
android:inputType="textEmailAddress|text"
android:textColor="@color/ColorBlackPrimary"
android:textSize="@dimen/text_small"
/>
TextView#setCompoundDrawables
。 - pskink