How to set WebView Content in Center?

后端 未结 2 1157
别跟我提以往
别跟我提以往 2021-01-16 03:18

I am loading some HTML content in WebView but its always coming in the top left corner of my WebView.

I have tried to use stylesheet also, in stylesheet I have added

相关标签:
2条回答
  • 2021-01-16 03:40

    try this:

    <html>
    <head>
      <style type="text/css"> 
    @font-face { font-family: MyCustomFont;  
    src:url("~/android_asset/fonts/MyriadPro-Regular.otf") } 
    #text{ font-family: MyCustomFont; 
    font-size:14; 
    text-align: center;
    margin:350px;
    line-height: normal;
    color:blue;
    height:20px;
    width:100px;
    margin:auto;
    background-color:red;
    } 
    </style> 
    </head>
    <body>
    <p id="text"> Hello World</p>
     </body>
    </html>  
    

    And I think that your address source font is mistake!

    0 讨论(0)
  • 2021-01-16 04:01
    <WebView android:id="@+id/webview1" 
      android:layout_gravity="center"
      android:scaleType="centerInside"
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent"
      android:adjustViewBounds="true">
    

    it might help you.

    0 讨论(0)
提交回复
热议问题