欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

Android 中的两端对齐实例详解

程序员文章站 2024-02-17 17:53:58
  在android中的webview中,可以对文本内容进行对齐,具体方法如下 public class mainactivity ext...

  在android中的webview中,可以对文本内容进行对齐,具体方法如下

  
public class mainactivity extends activity { 
  
  @override 
  protected void oncreate(bundle savedinstancestate) { 
    super.oncreate(savedinstancestate); 
    setcontentview(r.layout.activity_main); 
  
    string htmltext = " %s "; 
    string mydata = "hello world! this tutorial is to show demo of displaying text with justify alignment in webview."; 
  
    webview webview = (webview) findviewbyid(r.id.webview1); 
    webview.loaddata(string.format(htmltext, mydata), "text/html", "utf-8"); 
  } 
} 

activity_main.xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" 
  xmlns:tools="http://schemas.android.com/tools" 
  android:layout_width="match_parent" 
  android:layout_height="match_parent" 
  tools:context=".mainactivity" > 
  
  <webview 
    android:id="@+id/webview1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
  
</relativelayout> 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!