[android studio]Android 中的两端对齐实例详解

更新时间:2021-06-10    来源:文本特效    手机版     字体:

【www.bbyears.com--文本特效】

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

 代码如下

publicclassMainActivityextendsActivity {

   

  @Override

  protectedvoidonCreate(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:

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  tools:context=".MainActivity">

   

  

    android:id="@+id/webView1"

    android:layout_width="match_parent"

    android:layout_height="match_parent"/>

   

本文来源:http://www.bbyears.com/wangyetexiao/122942.html

热门标签

更多>>

本类排行