Custom theme dialog : transparent background

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Custom theme dialog : transparent background

Postby tikimove » Wed Jul 29, 2009 5:05 pm

Hi all,

I'm trying to make a custom theme dialog, which extends android:Theme.Dialog :

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <style name="RunesDialog" parent="@android:style/Theme.Dialog">
  3.  
  4.                 <item name="android:windowBackground">@drawable/cadre_dialogue
  5.  
  6.                 </item>
  7.  
  8.                 <item name="android:buttonStyle">@style/button</item>
  9.  
  10.                 <item name="android:textViewStyle">@style/textview</item>
  11.  
  12.                 <item name="android:editTextStyle">@style/edittext</item>
  13.  
  14.         </style>
  15.  
  16.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


So I can use it in the manifest :
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <activity android:name=".act.MyActivity" android:theme="@style/RunesDialog" />
  3.  
  4.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


If I directly use the android:Theme.Dialog theme, the background is transparent, but if I use RunesDialog, the background is always black. Can you help me with that ?

Thanks a lot

Just for information, here is the Theme.Dialog description from Android source code :
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.     <style name="Theme.Dialog">
  3.  
  4.         <item name="android:windowFrame">@null</item>
  5.  
  6.         <item name="android:windowTitleStyle">@android:style/DialogWindowTitle</item>
  7.  
  8.         <item name="android:windowBackground">@android:drawable/panel_background</item>
  9.  
  10.         <item name="android:windowIsFloating">true</item>
  11.  
  12.         <item name="android:windowContentOverlay">@null</item>
  13.  
  14.         <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
  15.  
  16.         <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
  17.  
  18.     </style>
  19.  
  20.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
Attachments
device.png
It shouldn't be black arround the window :/
device.png (13.08 KiB) Viewed 20147 times
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Top

Postby tikimove » Fri Jul 31, 2009 1:24 pm

any help ?
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Postby xinyu391 » Thu Aug 13, 2009 3:35 am

What's your @drawable/cadre_dialogue ?
is it transparent?
xinyu391
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Aug 13, 2009 3:32 am

Postby tikimove » Thu Aug 13, 2009 8:52 am

Hi,

Here is the cadre_dialogue image. It's a nine patch.
Attachments
cadre_dialogue.9.png
cadre_dialogue
cadre_dialogue.9.png (1.44 KiB) Viewed 20086 times
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Postby mad.dogg » Thu Aug 13, 2009 9:00 am

Hi, I'm just curious how does it look without the

<item name="android:windowFrame">@null</item>

line?
If it's boring it ain't heavy enough!
mad.dogg
Developer
Developer
 
Posts: 42
Joined: Tue May 20, 2008 2:18 pm
Location: Bulgaria

Postby tikimove » Thu Aug 13, 2009 12:44 pm

Thanks for the tip, I will test ASAP and let you know.
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Top

Postby mad.dogg » Sat Aug 15, 2009 9:00 pm

tikimove wrote:Thanks for the tip, I will test ASAP and let you know.

Any luck?
If it's boring it ain't heavy enough!
mad.dogg
Developer
Developer
 
Posts: 42
Joined: Tue May 20, 2008 2:18 pm
Location: Bulgaria

Postby tikimove » Tue Aug 18, 2009 10:22 am

Sorry I don't have the time to try but the problem is magically solved :shock: The background is transparent now :?
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Postby Bosicc » Wed Sep 09, 2009 6:42 pm

Hi All!

I have the same problem with background transparency.

I made my Theme.CustomDialog

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.     <style name="Theme.RCAlertDialog" parent="android:style/Theme.Dialog">
  2.  
  3.         <item name="android:windowBackground">@drawable/filled_box</item>
  4.  
  5.     </style>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4

but when I use it in AndroidManifest file background is BLACK.
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  <activity android:name=".alert.CustomAlert"
  2.  
  3.                android:label="test title"
  4.  
  5.                android:theme="@style/Theme.RCAlertDialog">
  6.  
  7.             <intent-filter>
  8.  
  9.                 <action android:name="android.intent.action.MAIN" />
  10.  
  11.                 <category android:name="android.intent.category.SAMPLE_CODE" />
  12.  
  13.             </intent-filter>
  14.  
  15.         </activity>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


If I use @android:style/Theme.Dialog then Background transperent, but apearence of my window as in standart dialog :(

Do you have any ideas how to use custom style for dialog? Can you check this tutorial?
User avatar
Bosicc
Freshman
Freshman
 
Posts: 7
Joined: Wed Sep 09, 2009 4:08 pm

Postby tikimove » Wed Sep 09, 2009 8:54 pm

Actually I don't know why, but even if it doesn't work on the emulator, sometimes it works on the real device. I can't understand :/
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Postby Bosicc » Thu Sep 10, 2009 4:28 pm

Today, I solve the problem. I just reboot my PC. And Run again Emulator and all works fine. I think it's a little bag of Emulator.
User avatar
Bosicc
Freshman
Freshman
 
Posts: 7
Joined: Wed Sep 09, 2009 4:08 pm

Postby FreakDev » Sun Nov 15, 2009 3:49 pm

hi guys,

i had the same pb... neither emulator reboot nor real device reboot solve my pb...

but i solve it by copying the "<item name="android:windowIsFloating">true</item>"

in my custom theme

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <resources>
  5.  
  6.   <style name="Theme" parent="android:Theme"></style>
  7.  
  8.  
  9.  
  10.   <style name="Theme.CustomTheme" parent="@android:style/Theme.Dialog">
  11.  
  12.         <item name="android:windowIsFloating">true</item>          
  13.  
  14.   </style>  
  15.  
  16. </resources>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Edit : oups... it works only on the virtual device, but not on the real one (G1 with cupcake)
FreakDev
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sun Nov 15, 2009 3:42 pm

Postby markww » Mon Nov 16, 2009 11:15 am

I had the same problem with creating a transparent dialog background - this works on 1.5 emulator / G1, and on 1.6 / 2.0 emulator - anyone running 1.6/2.0 on a real device to test there too? This was agonizing:

<style name="Theme.TransparentDlgTest">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>

Thanks
markww
Freshman
Freshman
 
Posts: 9
Joined: Sun Feb 24, 2008 7:36 am

Postby FreakDev » Tue Nov 17, 2009 8:56 am

it still works fine on emulator, but still not working on real device...

I try "setTheme()", and creating layout in java code, style with parent (android:style/Theme.Dialog), without parent (but all items)

but nothing do the job... :(
FreakDev
Junior Developer
Junior Developer
 
Posts: 12
Joined: Sun Nov 15, 2009 3:42 pm

Postby markww » Tue Nov 17, 2009 9:15 am

Hi,

Can you please try this again to verify it didn't work for you? This worked for me, even on my G1. Add this to your res/values/styles.xml file:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.     <style name="Theme" parent="android:Theme.Light">
  3.  
  4.     </style>
  5.  
  6.  
  7.  
  8.     <style name="Theme.TransparentTest">
  9.  
  10.       <item name="android:windowBackground">@android:color/transparent</item>
  11.  
  12.       <item name="android:windowFrame">@null</item>
  13.  
  14.       <item name="android:windowContentOverlay">@null</item>
  15.  
  16.       <item name="android:windowIsFloating">true</item>
  17.  
  18.       <item name="android:backgroundDimEnabled">true</item>
  19.  
  20.       <item name="android:windowIsTranslucent">true</item>
  21.  
  22.       <item name="android:windowNoTitle">true</item>
  23.  
  24.       <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
  25.  
  26.      </style>
  27.  
  28.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


then in your manifest file, pick some activity and apply the style:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.   <activity android:name="MyActivity"
  3.  
  4.     android:theme="@style/Theme.TransparentTest">
  5.  
  6.   ...
  7.  
  8.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


when you start that activity, the background should be transparent. Let me know if it works.

Thanks
markww
Freshman
Freshman
 
Posts: 9
Joined: Sun Feb 24, 2008 7:36 am

Top
Next

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests