【发布时间】:2014-03-08 19:02:48
【问题描述】:
我正在使用WebView 来证明文本的合理性。我想知道-
是否可以在
layout文件中设置文本大小?因为我想要不同屏幕尺寸的不同文本尺寸。还有一个问题是第一个背景出现,然后在 2 秒文本显示后出现。是否可以立即显示文字?
文字大小为 7-8 行。
代码-
public class Main extends Activity {
WebView mWebView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webview);
String text = "<html><body>"+"<p align=\"justify\">"+getString(R.string.itext)+"</p>"+"</body></html>";
mWebView .loadData(text, "text/html", "utf-8");
mWebView .setBackgroundColor(Color.TRANSPARENT);
}
}
Xml-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/light">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"/>
</LinearLayout>
【问题讨论】:
-
您是否使用设备测试过您的应用程序?
-
是的,我在设备上测试我的代码。
-
如果去掉透明度会提高性能吗?
标签: android webview text-size text-justify