源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Android 中的两端对齐实例详解

  • 时间:2021-07-13 22:45 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Android 中的两端对齐实例详解
  在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> 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部