Closed jamescarl15 closed 3 years ago
Create file item_power_menu.xml in your layout directory and paste the code below
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/item_power_menu_layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:clickable="true" android:focusable="true" android:foreground="?android:attr/selectableItemBackgroundBorderless" android:orientation="horizontal" tools:ignore="UnusedAttribute">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/item_power_menu_icon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="7dp"
android:layout_marginLeft="7dp"
android:scaleType="fitXY" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/item_power_menu_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif"
android:lineSpacingExtra="6sp"
android:padding="13dp"
android:textColor="@color/black"
android:textSize="14sp"
android:textStyle="bold"
tools:text="All Contents" />
For me the error was due to
android:foreground="attr/selectableItemBackground"
so I replaced these with
android:foreground="?android:attr/selectableItemBackgroundBorderless"
As I research, I noticed that the popup dialog are not recommended by Android Design. here's the link
So if you are building a floating app using a service, just improvised. You can create a popup dialog by hiding and showing it to your floating layout
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class <unknown>
I used the code in Activity class and it works fine, but in Service class its not.