Is it possible to create an Options Menu without an Action Bar on Android?

Asked

Viewed 140 times

0

I am creating a Profile screen, and would like to put a Options Menu with the options 'Edit Profile' and 'Quit'. The problem is that I don’t have an Action Bar on this screen, and I don’t want to put one, but I would like to create this Options Menu in the upper right corner of the screen. Is that possible? How can I do this?

inserir a descrição da imagem aqui

the XML of this screen is like this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/greylight"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="300dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="260dp"
            android:orientation="vertical"
            android:background="@drawable/gradient_background_profile">

            <ImageView
                android:layout_marginTop="35dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:src="@drawable/profile"/>

            <TextView
                android:layout_marginTop="10dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:text="Caíque Araujo"
                android:textColor="@color/white"
                android:textStyle="bold"
                android:textSize="21sp"/>

            <TextView
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:text="Universidade Federal do Ceará"
                android:textColor="@color/white"
                android:textSize="15sp"/>

        </LinearLayout>

    </RelativeLayout>

</LinearLayout>
  • 2

    Use a Toolbar, which can be placed anywhere in the code, and you can inflate a menu into it. But the way you want to do it, you can put a transparent actionbar, and make the content appear behind it, or increase the image’s top and bottom padding to the size of the transparent actionbar (56dp)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.