1

enter image description here

I want to add icon like the above images in android How can I do it

This is my menu.xml at the moment, I try to use android:icon, it is not showing

<menu 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"
    tools:context="com.example.kahheng.smartchat.MainActivity">
    <item
        android:id="@+id/action_poll"
        android:orderInCategory="100"
        android:layout_width="35dp"
        android:layout_height="50dp"
        android:title="@string/action_poll"
        android:icon="@mipmap/pollbtn"
        app:showAsAction="always" />
    <item
        android:id="@+id/action_draw"
        android:orderInCategory="100"
        android:layout_width="35dp"
        android:layout_height="50dp"
        android:title="@string/action_draw"
        android:icon ="@mipmap/drawbtn"
        app:showAsAction="always" />
    <item
        android:id="@+id/action_bookmark"
        android:orderInCategory="100"
        android:layout_width="35dp"
        android:layout_height="50dp"
        android:icon="@drawable/sendbtn"
        android:title="@string/action_bookmark"
        app:showAsAction="always" />
</menu>

what can I do to make the icon appear?

This is my mainactivity

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId())
        {
            case R.id.action_draw:
                Intent newActivity = new Intent(MainActivity.this, DrawingActivity.class);
                startActivity(newActivity);
                break;

            //Me
            case R.id.action_poll:
                Intent pollActivity = new Intent(MainActivity.this, pollActivity.class);
                startActivity(pollActivity);
                break;

            case R.id.action_bookmark:
                Intent bookmarkActivity = new Intent(MainActivity.this, bookmarkActivity.class);
                startActivity(bookmarkActivity);
                break;

        }


        return true;
    }
Ryan
  • 155
  • 1
  • 5
  • 19

0 Answers0