Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

110
Visualizações
How I center my HTML iframe in Android webivew?

I have an iframe in my Android webview that I am loading like this:

     String folderPath = "file:android_asset/";
     String fileName = "index.html";
     String file = folderPath + fileName;
     webView.loadUrl(file);

The iframe is loaded via HTML and CSS files located in my android/assests folder. The HTML and CSS look like this. HTML:

<!DOCTYPE html>
<html lang="en">
<body>
<link rel="stylesheet" type="text/css" href="default.css"  />
    <div class="abs-frame-container">
    <iframe 
      id="my_frame"
      src="my web page link"
      scrolling="no"
      allowtransparency="true" 
      style="border:none;overflow:hidden">
    </iframe>
    </div>
</body>
</html>

and my CSS

#my_frame {
  position: absolute;
  top: 0%;
  bottom: 0%;
  right: 0%;
  width: 117%;
  height: 100%;
}

#abs-frame-container{
    top: 10%;
    bottom: 0%;
    position: relative;
}

The webpage in iframe shows fine in the webview. I want to center (vertical alignment) my iframe in the webview so that it aligns automatically based on the webview dimensions (height). Would appreciate a lot if someone could help me how this can be achieved?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can call custom JavaScript on WebView directly from Java/Kotlin. It is explained in the official documentation.

You can then make JavaScript script that adds CSS styles to parts of loaded html page, and center your iframe that way.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda