Trong ứng dụng của tôi, tôi sử dụng drawables vector thêm trong thư viện hỗ trợ 23,2 cho các biểu tượng vector hiển thị và nó hoạt động hoàn hảo nhưng khi tôi đặt vector để drawableLeft của EditText nó không hoạt động trong các phiên bản Android trước kẹo. Khi chạy, ResourceNotFound exception xảy ra.EditText drwableLeft không làm việc với vectơ
Caused by: android.content.res.Resources$NotFoundException: File
res/drawable/layer_ic_user.xml from drawable resource ID #0x7f0200b3
Đây là cấu hình gradle tôi:
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:
<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"
/>
sử dụng 'TextView # setCompoundDrawables' – pskink
http://stackoverflow.com/questions/35739743/file-res-drawable-abc-ic-ab-back -material-xml-from-drawable-resource-id-0x7f020 –
@pskink làm cách nào tôi có thể sử dụng TextView # setCompoundDrawables –