How to create special activity?

susu

Well-Known Member
Licensed User
Longtime User
I just wonder how to create special activity like this?

2-this-is-the-level-of-information-presented-by-battery-indicator-pro.jpg
 

susu

Well-Known Member
Licensed User
Longtime User
Thanks Erel.

For who want to do it:

1. Set Activity to transparent with this line
Activity.Color = Colors.Transparent

2. Edit AndroidManifest.xml file
From
<activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main" android:label="abc" android:screenOrientation="unspecified">
To
<activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main" android:label="abc" android:screenOrientation="unspecified" android:theme="@android:style/Theme.Translucent.NoTitleBar">

3. Check "Do not ovewrite Manifest file" in B4A IDE.

That's all :D
 
Last edited:
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
I upload example code for who need it.
 

Attachments

  • TransparentExample.zip
    19.5 KB · Views: 430
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Hmmm...I tried making a Transparent Activity but it's not transparent.

I added this in my manifest:

SetActivityAttribute(main, android:theme, "@android:style/Theme.Translucent.NoTitleBar")

My Activity is called Trans and I call it from my Main using StartActivity("Trans"). It just pops up a Hello msg but I expected the existing background (on Main) to remain in view and just see the popup msg, but the screen clears to black and then the Hello msg pops up.

B4X:
'Activity module Trans
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.Color = Colors.Transparent
End Sub

Sub Activity_Resume
   Dim ct1 As CustomToast
   ct1.Initialize
   ct1.Show("Hello",3000,Gravity.TOP,0,Main.pScreenHeight * 0.50)
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
Here is one of the transparent examples I'm attaching as a .zip file. When I run this app the whole background is black. Obviously I'm thinking it should be transparent. I must be missing something!

Here is the manifest:

AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetActivityAttribute(main, android:theme, "@android:style/Theme.Translucent.NoTitleBar")
 

Attachments

  • transparent.zip
    5.8 KB · Views: 203
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
I got it to work on my Droid2 ok. I see that you have to have a View, in your case you had a Panel and a button and made the panel transparent.

I added a Panel to my test app and the Activity went transparent.

Thanks for your help Margret!
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
@Margret

I wrote a second transparent test app to make sure I could do it with a clean app, but it won't go transparent! I'm attaching it as a .zip file, would you mind taking a quick look at it and see if it goes transparent on your device?

Thanks...
 

Attachments

  • Trans2.zip
    6.1 KB · Views: 233
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
@Margret

I wrote a second transparent test app to make sure I could do it with a clean app, but it won't go transparent! I'm attaching it as a .zip file, would you mind taking a quick look at it and see if it goes transparent on your device?

Thanks...

It doesn't look like you have editted the manifest...
 
Upvote 0

barx

Well-Known Member
Licensed User
Longtime User
Just tested...

You need to add the following line to manifest.

B4X:
SetActivityAttribute(main, android:theme, @android:style/Theme.Translucent.NoTitleBar)
 
Upvote 0
Top