3
일부 HTML 코드가 있는데이를 WebView에로드합니다. 나는 퍼센트로 단추 너비를 설정해야한다 (화면 해상도에 의존하지 않기 위해).Webview에서 HTML 버튼의 너비를 백분율로 표시합니다.
버튼의 너비를 퍼센트로 설정하면 page cannot be loaded
butf로 설정할 수 있습니다. 픽셀로 설정하면 문제가 없습니다.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type='text/css'>
body{ position: relative; }
button { width: 50%; display: block; position: relative; }
</style>
</head>
<body style='text-align:justify;color:white;'>
Some text
<br/>
<button>Boo!</button>
</body>
</html>
의견이 있으십니까?
편집 : 솔루션이 페이지 후 기능이로드 된 JS를 호출 화면 폭을 얻고 요소에 설정하여 잭의 조언, 즉, @ 기반으로 발견되었다
.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language='javascript'> function SetWidth(){ d = document.getElementById('but'); d.style.width=screen.width/2; } </script>
<style type='text/css'> body{ position: relative; } button { display: block; position: relative; } </style>
</head>
<body style='text-align:justify;color:white;'>
Text<br/>
<button id='but' >Scary!</button>
<script> window.onload=SetWidth; </script>
</body>
</html>
감사합니다. 작동합니다! 질문이 편집되었습니다. – nicolausYes