J'ai été à travers une douzaine d'exemples de cela, une douzaine d'erreurs relatives à cela, et pour une raison quelconque, mes images ne fonctionnent pas.Image comme arrière-plans de bouton - CRASH et de travail
Toutes les images sont inférieures à 800 x 800 pixels et inférieures à 200 ko, et toutes au format .png.
J'ai plusieurs fragments avec plusieurs images dans chaque fragment. J'ai ajouté des boutons avec des images d'arrière-plan comme ci-dessous.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Please select" />
<Button
android:id="@+id/broad_btn"
android:layout_width="@android:dimen/notification_large_icon_width"
android:layout_height="@android:dimen/notification_large_icon_height"
android:background="@drawable/broad"
android:tag="broad"
android:text="Broad" />
</Linearlayout>
Maintenant, l'image sur le second fragment que j'ai n'est pas différente de celle ci-dessus. Cependant, mon application se bloque lorsque j'essaie de l'utiliser en arrière-plan. Cependant, si j'utilise l'image "problème" sur la première page - alors cela fonctionne très bien. Ce n'est que lorsque je déplace cette image vers le second fragment qu'elle échoue.
Le code pour le second est
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<Button
android:id="@+id/late_btn"
android:layout_width="@android:dimen/notification_large_icon_height"
android:layout_height="@android:dimen/notification_large_icon_height"
android:background="@drawable/late"
android:text="Long" />
</LinearLayout>
Quelle erreur obtenez-vous? –