Search code examples
androidimageimagebuttonimageiconandroid-imagebutton

How to Use predefined Android Resources in Android Application?


I have been developing a conversation app. I built an APK(Nougat) and sent to my friends to test. One of my friend didn't get the send icon correctly(marshmallow). I have given rocket icon to send the message. but in his mobile he can able to see only message icon. Also another friend didn't get background image but rocket icon is visible for him(Lollipop). snapshots attached below.

please help me to rectify this error.

<ImageButton
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:layout_weight="7"
        android:padding="4dp"
        android:id="@+id/send_button"
        app:srcCompat="@android:drawable/ic_menu_send"
        android:background="@android:color/transparent"
        android:tint="@color/colorAccent"
        android:contentDescription="@string/send_to_watson_button" />

and for background i used like this..

<android.support.design.widget.CoordinatorLayout
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:fitsSystemWindows="true"
tools:context="com.ibm.watson_conversation.MainActivity"
android:background="@drawable/tilerepeat">

Wrong Image

Wrong Image

Expected Image

Expected Image


Solution

  • @EugenPechanec is right. Each android ROM has its unique set of resources/icons. @android:drawable accesses the icons according to the ROM the apk is installed on. It has nothing to do with the way you designed the application.

    What you should do however is get an icon off the internet [Just for testing. For commercial use you need to design your own icons] that you want to be used on all phones, copy it into your res> drawable folder, then use @drawable/iconnamehere . This way the icon will be uniform on all devices.