简体   繁体   English

文字说明无效

[英]Text justify didnt work

I took this and paste in a new android, with a few changed in other files, it didn't type anything in the applicatin, like this http://oi60.tinypic.com/2rw5lco.jpg ... does anyone know why? 我将其粘贴到一个新的android系统中,在其他文件中进行了一些更改,在applicatin中未键入任何内容,例如http://oi60.tinypic.com/2rw5lco.jpg ...没有人知道为什么?

package com.f.fa;

import android.os.Bundle;
import android.app.Activity;
import android.webkit.WebView;

public class PageAbus extends Activity
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {

       super.onCreate(savedInstanceState);
       setContentView(R.layout.abus);

       String text = "<html><body style=\"text-align:justify\"> %s </body></Html>";

       String data = "The power of theory lies in its ability to spare us from doing useless things. The power of theory lies in its ability to spare us from doing useless things.";

       WebView webView = (WebView) findViewById(R.id.abussort);
       webView.loadData(String.format(text, data), "text/html", "utf-8");

    }

}

EDIT Here is the xml 编辑这是XML

   <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#1d72c3"
        android:gravity="center" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:gravity="center"
            android:orientation="vertical"
            android:textStyle="italic" >

            <ScrollView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <WebView
                        android:id="@+id/abussort"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:gravity="center"
                        android:textColor="#ffffff"
                        android:textSize="21sp"
                        android:textStyle="italic" />
                </LinearLayout>
            </ScrollView>
        </LinearLayout>

    </RelativeLayout>

You should add this permission in manifest file: 您应该在清单文件中添加此权限:

<uses-permission android:name="android.permission.INTERNET" />

Check this link 检查此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM