Android Question Image/Picture on each activity via manifest file

artsoft

Active Member
Licensed User
Longtime User
Hi dears!

Today I have a question to you regarding the possibilty to draw an image/picture on each activity at a specific position (x,y,w,h) within the manifest file:

Currently I created my own resource as a color gradient (mygradient.xml) for each activity:

Manifest file:
'
CreateResource (drawable, mygradient.xml,
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
        <gradient android:angle="90" android:startColor="#FF003264" android:endColor="#FF0064FF" android:type="linear"/>
    </shape>
)
'  
SetApplicationAttribute(android:theme, "@style/LightThemeArtsoft")
    CreateResource(values, theme.xml,
        <resources>
            <style name="LightThemeArtsoft" parent="@style/Theme.AppCompat.NoActionBar">
                <item name="android:windowBackground">@drawable/mygradient</item>
            </style>
        </resources>
)
'
...

This works perfectly on each device.

________________________________________________________________________


But now, I need an image at the left upper corner on each activity - but I dont want to draw it every time in the designer (and in the CREATE method).

Therefore my question:
Is there any way to draw a specific bitmap (as a resource) to an activity via MANIFEST file?


I am thankful for any help.

Best regards
ARTsoft
 

artsoft

Active Member
Licensed User
Longtime User
Thanks Erel for this tip.

The main problem I see now is, that there is a flickering of each activity. On all Samsungs (S3, S6 etc.) there is no flickering at all!!!

But on my other smartphones (i. E. Oppo Reno 2Z) there is a deletion of the complete activity screen after the command "StartActivity(activityname)". There is a redrawing of the activity with black color first, then in the CREATE method the loading the layout for the current activity (layout created with the B4A designer).

The app logo which is displayed on each activity (via layout) is then redrawed every time I switch the activity.

Good news:
The black screen redraw problem was eliminated by using the manifest code above - by using the gradient theme. So far, so good.

Therefore I thought, I could also aliminate the redrawing issue of the logo image by creating and positioning a resource image file via manifest file (similiar the gradient resource above).

I also tried to use an RES/ANIM/xml file (i. e. slide_in_left.xml):

XML:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="100%p" android:toXDelta="0"
    android:duration="@android:integer/config_shortAnimTime"/>

But I dont want such an animation movement on the screen.
I want to have the same effect as on my Samsung devices: Simple show the next activity - without any animations, redrawing etc. I hate them!

I looked many times the complete forum here, and I could find a lot of similiar problem the users have - regarding this "flickering" or "black screen" issue.
But no solution helped my here in my case.

So, Erel, what could I do? Whats wrong here?
On Oppo I have Android 10, on Samsung S6 there is Android 7.

Many regards
ARTsoft
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
In the Designer did you take care of setting Animation of Activity to 0 (zero)?
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
In the Designer did you take care of setting Animation of Activity to 0 (zero)?

Yes, of course! Every activity has value of 0.

I call this Sub-method every time in each activity (Resume, Pause, Create, before StartActivity ... Believe me, I already tried all combinations):

B4X:
Sub SetNoAnimation()
   
    Private r As Reflector
   
    Try
        r.Target = r.GetActivity
        r.RunMethod4("overridePendingTransition", Array As Object(0, 0), Array As String("java.lang.int", "java.lang.int"))
    Catch
        'no opcode currently here...
    End Try
   
End Sub

Nevertheless, thanks.

Regards
ARTsoft
 
Last edited:
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
It seems that the method "StartActivity" invalidates the complete screen for the next update. It could be that Samsung OS handles all commands in another way as Oppo or other devices do.

How I can avoid this invalidation ... this flickering?

I am pretty sure that there is a workaround for this.
But how to find it....

Thanks all in advance for helping.

Regards
ARTsoft
 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Upvote 0

artsoft

Active Member
Licensed User
Longtime User

Thanks, but this doesn't help me.
I would like to know what's the difference between the two devices while running the same app.

I eliminate all code from CREATE, RESUME and PAUSE method.
Only the command Activity.LoadLayout("xxxxxx") is still present.

But this has the same effect: The logo (imageView) is redrawn every time.

Within the designer I assigned an image directly to the imageView. Could be that this is the cause?

So I decided to delete this (designer-)assignment and assigned the logo-image by code:

B4X:
ImageView1.Bitmap = LoadBitmapSample(File.DirAssets, "logo.png", ImageView1.Width, ImageView1.Height)

But unfort. no success :-(

Regards
ARTsoft
 
Upvote 0
Top