Вылетает активити
При переходе из одного активити в другое приложение просто закрывается, если убираю строчку app:srcCompat="@drawable/ach1" то не вылетает. Что не так c этой строчкой?
?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/achievfon">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/str_nag"
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginTop="80dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="60dp"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="171dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
app:srcCompat="@drawable/ach1" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
добавил vectorDrawables.useSupportLibrary = true, все равно вылетает
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.testappv1"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
Ответы (1 шт):
Автор решения: Barmaley
→ Ссылка
атрибут app:srcCompath используется для внедрения векторных картинок, при условии, что есть его поддержка на уровне библиотек:
Надо добавить в gradle:
vectorDrawables.useSupportLibrary = true
Update
Обычные (растровые) картинки вставляются просто:
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="171dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:src="@drawable/ach1" />
Растровые картинки - это изображение состоит из пикселей, а векторные из векторов (линии, кружочки и т.д.)