简体   繁体   中英

How to make an opaque Activity?

I'm using QuickAction3D library and I would like to make the background sort of opaque when the QuickAction it's clicked, just like a normal AlertDialog would do, it's there a way of doing this?.

Thank you very much

EDIT

I meant the Activity go to an opaque color, and the quick action preserve it's current color. For example, If an AlertDialog it's shown, the background activity would be turned opaque, and the AlertDialog it's on a clear color.

Quich action 3d See in that library for the background they have used a selector drawable action_item_btn.xml , you can customize the code to make as per ur need.They have set as

 <item 
    android:state_pressed="true"
    android:drawable="@drawable/action_item_selected"/>

for the background if u want to set the selector for the items in the list u can set selector for the imageView present there like,

Create a background drawable resource, eg item_background.xml , in your /drawable folder, containing something like this:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:drawable="@color/color1" android:state_pressed="true"/>
  <item android:drawable="@color/color2" android:state_selected="true"/>
  <item android:drawable="@color/color3" android:state_activated="true"/>
  <item android:drawable="@color/color4"/>
</selector>

Then provide the color values in your /values/colors.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="color1">#DDff8800</color>
  <color name="color2">...</color>
  <!-- more colors... -->
</resources>

Finally, set that drawable resource as the item background in your layout with android:background="@drawable/item_background" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM