Problems setting the layout

0

I can not get you to accept this layout definition for Web View size:

<RelativeLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:paddingLeft="5dp" 
     android:paddingRight="5dp">
  <TextView 
      android:id="@+id/title" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:text="@string/title" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:textStyle="bold" /> 
 <ScrollView android:id="@+id/sv" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_below="@+id/title" 
     android:layout_marginTop="10dp">
 <RelativeLayout 
     android:layout_width="fill_parent"
     android:layout_height="wrap_content">
  <WebView android:id="@+id/desc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="5dp" 
      android:scrollbarStyle="insideOverlay" 
      android:text="@string/desc" /> 
  </RelativeLayout>
  </ScrollView>
  </RelativeLayout>

In the whole WebView tag, this error occurs: Placing a in a parent element that uses wrap_content size can lead to subtle bugs; use match_parent.

    
asked by anonymous 27.10.2014 / 20:54

1 answer

1

I do not know the purpose very well, but it is not recommended to leave your WebView with limited size, the idea is that it always occupy the maximum possible screen, using layout_height="match_parent" .

Since the WebView itself already has scroll, you do not have to use a ScrollView in it. In addition I gave a simplified one in its layout, being:

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

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/title"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textStyle="bold" />

    <WebView
        android:id="@+id/desc"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_marginTop="5dp"
        android:scrollbarStyle="insideOverlay"
        android:text="@string/desc" />

</LinearLayout>
    
27.10.2014 / 23:46