Android Question Transparent Activities in Project

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings.

Thank you in advance for answering my question.

Case:
Application with 4 activities: Main, Act1, Act2, and Act3
1. Main is Full Screen and No Title
2. Would like remaining activities to be transparent and consist solely of a panel with some controls.
3. Each Activity other than Main would behave like a modal form...
4. The panels in each of the Activities would be smaller than the Main Activity allowing the user to see the outer edges of the Main Activity in the background.

I am able to recreate the Transparent activity project found in:
http://www.b4x.com/android/forum/threads/transparent-activity.16814/#post-98854
but I am unable to carry out the concept to the multi-activity case I described above.

Any and all help would be welcomed.
 

udg

Expert
Licensed User
Longtime User
Hi tdocs2,

probably I can't fully understand your requirements, but won't it suffice to create a panel in each of the secondary Actx and then operating an AddView/RemoveView of that panel on the Main.Activity?
While Panelx shows you will intercept and consume any event you like so Main is out of game until you remove the panel.

Umberto
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User

Thank you, Umberto.

If I only have one activity, Main, then I can have a panel that I can add and remove. I think that is what you are leading to.

The case I present contains 4 activities. Main, Act1, Act2, Act3. I would like Act1, Act2, and Act3 to be transparent. I do not know how to achieve this. I understand that the Manifest file has to contain: android:theme="@style/Theme.Transparent" for Act1, Act2, and Act3, but I have no idea how to make that happen.

Does this clarify my description?

Thank you.

Sandy
 
Last edited:
Upvote 0

udg

Expert
Licensed User
Longtime User
Oh, now I see it.
Time for a large cup of coffee..
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
It is clear: you need a unique Activity (Main) and some Dialogs over it.

You can not have two Activities simultaneously... active.

You can create the dialog as follows:

Create a transparent panel (full screen) in the Main, in which you put another panel that contains the view. Then you show or hide the "parent" (external) panel through the Visible property.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Well before the much needed cup of coffee I tried the attached solution.
It somehow works but I doubt it's the way to go.
The dirty tricks is: calling LoadLayout twice in Act2 (first time to show Main layout, second time to show proper Act2 layout).
And since Act2 has no handlers for events related to Main objects (e.g. the button on the bottom-left corner) all those elements stay partially visible and unchanged, unless you use Act2.GetView(0..n), where n is the last element in first layout, to update some data there.


Umberto
crawling to the coffee machine..
 

Attachments

  • test2.zip
    8.5 KB · Views: 403
Last edited:
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User

Grazie, Luca.

I do understand that 2 activities cannot be "active" at the same time. And precisely, I want ONLY one activity to be active - thus my reference to a "modal" form (in VBx language).

However, I do not want the Main Activity style to be transparent. The Main activity is Full Screen and No Title. I want the remaining activities, Act1, Act2, Act3 to be transparent, i.e., android:theme="@style/Theme.Transparent" for activities Act1, Act2, and Act3. I know I could achieve this effect by adding panels to Main and then show or hide them. However, I already have a lot of code in Main and I wanted to segment some of it in different activities. I also know I could create Class modules with the use of the "panels in the Main Activity" solution, but for me, creating a Class module would be a more significant learning curve (which I will attempt in the future).

I am able to recreate the Transparent activity project found in:
http://www.b4x.com/android/forum/threads/transparent-activity.16814/#post-98854
but I am unable to carry out the concept to the multi-activity case I just described.

Cordiali saluti,

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User

Thank you, Umberto.

That must have been a large cup of coffee. You developed a muti-activity project in 12 minutes (less the time it took you to get the cup of coffee).

Very clever solution. However, the background layout would not be a "live screen capture" of Main, but the original layout.

Like in my response to Luca, there must be a way (and I certainly do not know enough) to set android:theme="@style/Theme.Transparent" for activities Act1, Act2, and Act3.

I am able to recreate the Transparent activity project found in:
http://www.b4x.com/android/forum/threads/transparent-activity.16814/#post-98854
but I am unable to apply the concept to Act1, Act2, and Act3 for my project. The manifest file for the Transparent activity project is:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.zerosoftbh.transparent"
      android:versionCode="1"
      android:versionName=""
      android:installLocation="internalOnly">
      <uses-sdk android:minSdkVersion="4" />
      <supports-screens
          android:largeScreens="true"
          android:normalScreens="true"
          android:smallScreens="true"
          android:anyDensity="true"/>
    <application android:icon="@drawable/icon" android:label="transparent">
     
        <activity android:windowSoftInputMode="stateHidden" android:launchMode="singleTop" android:name=".main"
                  android:label="transparent" android:screenOrientation="unspecified" android:theme="@style/Theme.Transparent">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
     

    </application>
 

</manifest>

Best regards.

Sandy

Via, Veritas, Vita
 
Last edited:
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
In the manifest editor use:
B4X:
SetActivityAttribute(Act1, android:theme, @style/Theme.Translucent)
to make that activity transparent.

Thank you, thedesolatesoul.

I get this error:

Generating R file. Error
AndroidManifest.xml:29: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Translucent').

This is the Manifest File:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetActivityAttribute(Act1, android:theme, @style/Theme.Translucent)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

Best regards.

Sandy
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Yes, you can create a transparent activity, but then? As you know, you can not start it without "close" the Main activity.

I'm sorry, but I think that you can only put all your code in the Main and use panels (or use classes, as you wrote), if you need (?) to overlay some "activities".

(Thank you for your greetings in Italian )
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi all,

maybe a silly question: what happens IF the Main activity gets destroyed by the OS while Act2 is showing on top of it?
If I read correctly the app life-cycle, when we leave Main to load Act2, Main resources could be claimed back by the OS on a lower memory status condition (and/or change of orientation?).
So a moment we have Act2 superimposed on Main and the moment after Act2 is showed on standard device background?

@Sandy:
That must have been a large cup of coffee. You developed a muti-activity project in 12 minutes (less the time it took you to get the cup of coffee).

That's why I think that defining B4A simply a RAD tool is too reductive! Maybe BFAD (Blazingly Fast Application Development) comes a little closer to our daily experience with it.

Umberto
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Try with quotes:
B4X:
SetActivityAttribute(Act1, android:theme, "@style/Theme.Translucent")

Thank you, thedesolatesoul.

Same error:

Generating R file. Error
AndroidManifest.xml:29: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Translucent').

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetActivityAttribute(Act1, android:theme, "@style/Theme.Translucent")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

I tried also Clean Project... Where does it resolve android:theme?

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
Thank you, Luca.

I plan to use NO code from Main - only data passed in Process Globals. I know that Main will be "closed" - only one activity at a time. I just want Act1, 2, 3, ... to take part of the screen and not the full screen. Act1, 2, 3 will not have Android menus. Main is:

B4X:
#Region Activity Attributes
#FullScreen: true
#IncludeTitle: false
#End Region

Sandy
 
Upvote 0

tdocs2

Well-Known Member
Licensed User
Longtime User
SetActivityAttribute(Act1, android:theme, "@android:style/Theme.Translucent")

You have got to love this community!!!

In about 10 hours - 16 postings, experts from Italy, England, and Switzerland understood my question (a little bit out of the ordinary) and I got the answer.

Luca,

This one worked - the syntax is right!

To all of you,

Thank you.
Grazie.
Gracias.
Merci.
Danke.

Sandy, FL USA
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…