문제

My WebView doesn't fill the entire width of my phone. I am telling to fill_parent. Not sure why?

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal">

    <WebView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/WebView"></WebView>
    </LinearLayout>
도움이 되었습니까?

해결책

The linear layout is orientation horizontal I don't think you can fill width on orientation horizontal.

Try using RelativeLayout instead. (just rename LinearLayout to RelativeLayout)

다른 팁

That size is being taken up by the webview's scroll bar. use this to get rid of it

browser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

In Activity layout (xml) and more specifically LinearLayout Tag contains some padding by default like: android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"

Delete that, set your WebView to fill_parent and then it will do the job.

I know in my xml you will fill the width up with no issues... check it out.

you will see i am using the wrap_content in my base LinearLayout

   <LinearLayout android:orientation="horizontal"  android:background="@drawable/dailygoal"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
       android:padding="3px"

      >         
            <WebView
        android:id="@+id/dailygoalswebview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:layout_gravity="right"
         android:padding="20px" 
        >
    </WebView>
             </LinearLayout>

I just applied the above xml to my main.xml layout... i hope you the best of luck..

In Activity layout (xml) either it may be relative or other layout it contains some padding by default like: android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin"

delete the above lines, and fill the width and height to be "fill_parent". this works

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top