Android 中的两端对齐实例详解

Ada ·
更新时间:2024-09-20
· 937 次阅读

  在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>

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

您可能感兴趣的文章:Andorid 日历控件库,可左右滑动,显示公历,农历,节假日等功能Android实现点击获取验证码倒计时效果Andorid自定义attr的各种坑Andorid TextView字幕效果实例Android编程实现自定义toast示例Android Material加载进度条制作代码Android 如何使用log4j及注意事项Android自定义Material进度条效果Android自定义View实现水波纹引导动画Android实现放大镜效果的方法实例(附源码)Android手机注册登录时获取验证码之后倒计时功能(知识点总结)android判断手机是否安装地图应用实现跳转到该地图应用Android点击EditText文本框之外任何地方隐藏键盘的解决办法Android中点击隐藏软键盘最佳方法Android中html.fromhtml的使用方法



两端对齐 Android

需要 登录 后方可回复, 如果你还没有账号请 注册新账号