0

I have an activity on top of another. I am using the below code as theme in the manifest file.

<style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:backgroundDimEnabled">true</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
</style>

It works totally fine. But click on any part of view has a orange background as selected area.

This is how it looks.

enter image description here enter image description here

Any idea how to solve it?

Arnold Laishram
  • 1,801
  • 2
  • 18
  • 25

1 Answers1

0

I did a quick fix by overriding background as custom drawable to all of my views present in that activity. But I want to follow a standard.

Here's how the code looks like.

I created a drawable called selectable_background for android below 21.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:drawable="@android:color/transparent" />
<item android:drawable="@color/color_clicked" />
</selector>

for android 21 and above

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ripple_black" />
</selector>

<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/color_clicked"/>

and added to all the views

android:background="@drawable/selectable_item_background"

Reference

Community
  • 1
  • 1
Arnold Laishram
  • 1,801
  • 2
  • 18
  • 25