2014-01-25 83 views
0

如何解决这个问题我使用Webview并设置了一个backgroundResource,怎样才能将文本居中放在webView中?WebView中的中心对齐文本?

这是我的XML代码

<WebView 
     android:id="@+id/webView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingBottom="10sp" 
     android:gravity="center" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="81dp" /> 

enter image description here

+0

能见度:尽量使用'gravity' –

+0

我已经做安卓重力=“中心”,但nothings发生:( – chicharp

+0

你从哪里得到这个文本? –

回答

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 

     <WebView 
      android:id="@+id/webview" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:visibility="gone" /> 

     <TextView 
      android:id="@+id/textView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:text="This is Textview.This is Textview.This is Textview.This is Textview.This is Textview.This is Textview.This is Textview.This is Textview.This is Textview." /> 
    </FrameLayout> 

</LinearLayout> 

使用这种设置和通过活动