Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the Navigation Bar #525

Open
FernandoBanhos opened this issue Nov 12, 2024 · 7 comments
Open

Hide the Navigation Bar #525

FernandoBanhos opened this issue Nov 12, 2024 · 7 comments

Comments

@FernandoBanhos
Copy link

Hi,

I created an application, using LAMW, I managed to make it full screen, but the navigation bar is visible, would it be possible to hide the navigation bar?

According to the website: https://developer.android.com/training/system-ui/navigation#java

How to do this in LAMW?

Thanks

@dosza
Copy link
Contributor

dosza commented Nov 16, 2024

Hello, You can try send an email to [email protected]

@jmpessoa
Copy link
Owner

Hi, Fernando!

Go to your project folder "\res\values" and paste here the ""styles.xml" content file....

@FernandoBanhos
Copy link
Author

FernandoBanhos commented Nov 18, 2024

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<resources>
<!-- 
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
     -->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!-- 
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
         -->
</style>
<!--  Application theme.  -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!--  All customizations that are NOT specific to a particular API-level can go here.  -->
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
</style>
</resources>

@jmpessoa
Copy link
Owner

"This XML file does not appear to have any style information associated with it....."

But it has!

You can read:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> and others "item name" properties... The strange thing is that everything seems correct.... can you post a screenshot of your application?

@jmpessoa
Copy link
Owner

Well, you can do some try:

1)in design: go to jForm and set the property ActionBarTilte = abtHide

and/or

2)in run time: handling jForm "OnJNIPrompt" event:

procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
begin
{if Self.HasActionBar() then}
Self.HideActionBar();
end;

@FernandoBanhos
Copy link
Author

"Este arquivo XML não parece ter nenhuma informação de estilo associada a ele....."

Mas tem!

Você pode ler:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> e outras propriedades de "nome do item"... O estranho é que tudo parece correto.... Você pode postar uma captura de tela do seu aplicativo?

foto

@FernandoBanhos
Copy link
Author

FernandoBanhos commented Nov 19, 2024

I found this function that solved the problem, would I be able to add it to LAMW sources, such as HideNavigationBar?

procedure TAndroidModule1.HideNavigationBar;
var
  jEnv: PJNIEnv;
  jParams: JObject;
  viewClass: jClass;
  setSystemUiVisibilityMethod: jMethodID;
  flags: Integer;
  args: array[0..0] of JValue;
begin
  // Obtém o ambiente JNI
  jEnv := gApp.Jni.jEnv;

  // Obtém a referência para o View do formulário principal
  jParams := Self.View;

  if jParams <> nil then
  begin
    // Define as flags para ocultar a barra de navegação e ativar o modo tela cheia
    flags := 2 {SYSTEM_UI_FLAG_HIDE_NAVIGATION} or
             4 {SYSTEM_UI_FLAG_FULLSCREEN} or
             4096 {SYSTEM_UI_FLAG_IMMERSIVE_STICKY};

    // Prepara o argumento
    args[0].i := flags;

    // Encontra a classe e o método para setSystemUiVisibility
    viewClass := jEnv^.GetObjectClass(jEnv, jParams);
    setSystemUiVisibilityMethod := jEnv^.GetMethodID(jEnv, viewClass, 'setSystemUiVisibility', '(I)V');

    // Chama o método setSystemUiVisibility com as flags desejadas
    jEnv^.CallVoidMethodA(jEnv, jParams, setSystemUiVisibilityMethod, @args);

    // Limpeza de referências locais
    jEnv^.DeleteLocalRef(jEnv, viewClass);
  end;
end;

procedure TAndroidModule1.fprincipalJNIPrompt(Sender: TObject);
begin
  HideNavigationBar;
end;

foto2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants