0

This is my code in list view layout xml file

   <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout 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="@android:id/empty"
        android:text="No schedules available"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </TextView>

    <ListView android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:drawSelectorOnTop="false"
        android:layout_gravity="right|bottom"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <ImageButton
        android:layout_width="89dp"
        android:layout_height="56dp"
        android:id="@+id/add_schedule"
        android:layout_gravity="right"
        android:src="@mipmap/ic_add_fab"
        android:background="#00ffffff"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />


    </RelativeLayout>

The button is visible in renderer but not in my emulator. Suggesstions would be a lot helpful This whole setup is in a master detail flow

user1140237
  • 5,015
  • 1
  • 28
  • 56
CatVsDogs
  • 342
  • 1
  • 11
  • 1
    Before doing anything I would recommend that you check your code in a real device because the appearance in both graphic renderer and emulator can be misleading. And as a side note, are you using Android Studio? – drWisdom Dec 27 '15 at 17:08
  • Yes I am using android studio – CatVsDogs Dec 27 '15 at 17:34
  • I think that you are setting up the image button as a floating action button (FAB). In that case you might be better of using the official FAB widget instead of creating your own. It is done as It will simplify your process and minimize odd behaviour – drWisdom Dec 27 '15 at 17:39
  • Tested in a real device still not working – CatVsDogs Dec 27 '15 at 17:43
  • Thank you I'll try that but even my menu bar is not appearing. I've followed all the steps in this post http://stackoverflow.com/questions/8308695/android-options-menu-in-fragment – CatVsDogs Dec 27 '15 at 17:46

1 Answers1

1

First of all, your button is displayed in emulator, but you don't see it, because it might be hidden under ListView.

You would said:

"My ListView is in the left bottom corner of RelativeLayout".

Partially you're right, but look - you set width as match_parent. Change this attribute to let's say 30dp and I'm sure you would see your button.

Try as others suggest Floating Action Button (FAB). Here's a nice tutorial how to use it properly: https://guides.codepath.com/android/floating-action-buttons

If you don't like standard implementation of it, look at this page: https://android-arsenal.com/tag/173

Hope it help

piotrek1543
  • 19,130
  • 7
  • 81
  • 94