Android 中的两端对齐实例详解
在android中的webview中,可以对文本内容进行对齐,具体方法如下
publicclassMainActivityextendsActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StringhtmlText="%s";
StringmyData="HelloWorld!ThistutorialistoshowdemoofdisplayingtextwithjustifyalignmentinWebView.";
WebViewwebView=(WebView)findViewById(R.id.webView1);
webView.loadData(String.format(htmlText,myData),"text/html","utf-8");
}
}
activity_main.xml:
<RelativeLayoutxmlns: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>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
热门推荐
10 毛笔哥哥结婚祝福语简短
11 向国庆送祝福语简短
12 建队节祝福语简短
13 朋友喜得外孙简短祝福语
14 小店营业的祝福语简短
15 餐饮生日祝福语简短独特
16 鲜花英语祝福语卡片简短
17 男朋友暴富祝福语简短
18 婶婶拜年祝福语大全简短