Problems when defining the layout

Asked

Viewed 99 times

0

I am unable to make you accept this layout definition regarding the size of the Web View:

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

Throughout the Webview tag comes out this error:Placing a in a Parent element that uses a wrap_content size can lead to subtle bugs; use match_parent.

1 answer

1

I’m not quite sure the purpose, but it’s not recommended to leave your WebView with limited size, the idea is that it always occupy as much screen as possible, using layout_height="match_parent".

Like the very WebView already have scroll, do not need to use a ScrollView in it. I also gave a simplified layout, getting:

<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>
  • I tried this way, in other ways, preferably with match_parent, but it is still smaller than ideal:http://dc544.4shared.com/img/Bdb3mEvwba/s3/14958605688/device-2014-10-28180801.png.

  • I saw that he took everything but the size of the title, wouldn’t that be it? You could mark on the image or put a padding and use a background to show the Webview border?

  • I’ll see here can be just that

Browser other questions tagged

You are not signed in. Login or sign up in order to post.