LinearLayout和Webview在ScrollVIew中的大小不同

时间:2012-09-05 13:42:16

标签: android webview scrollview

我有以下视图树:

  • RelativeLayout的
    • 滚动型
      • RelativeLayout的
        • web视图
        • LinearLayout(右边是webview)

加载网页后,我需要LinearLayout与WebView具有相同的高度。我怎么能这样做?

布局xml我正在使用

<ScrollView android:id="@+id/scroll_view" android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:fadingEdge="none" >

    <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:orientation="vertical">

        <RelativeLayout android:id="@+id/view_touchbutton" android:layout_width="50dp" android:layout_alignParentRight="true"
                      android:layout_height="fill_parent" android:background="@drawable/next_page_white" android:layout_alignParentTop="true"
                      android:gravity="center_horizontal">
            <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"
                       android:layout_marginTop="300dp"
                       android:src="@drawable/sipka_dalsi"
                       android:contentDescription="sipka"/>
        </RelativeLayout>

        <ImageView android:layout_width="fill_parent" android:layout_height="wrap_content"
                   android:id="@+id/imageview_content" android:contentDescription="image"
                   android:src="@drawable/bezobrazku_clanek" android:scaleType="fitXY"/>

        <LinearLayout android:id="@+id/layout_info_box" android:layout_width="fill_parent" android:layout_height="fill_parent"
                      android:layout_alignBottom="@id/imageview_content" android:background="#aa000000"
                android:orientation="vertical" android:gravity="left|center_vertical" android:visibility="gone">

        </LinearLayout>

        <ImageButton android:id="@+id/button_info_box_switch" android:layout_alignLeft="@id/imageview_content" android:layout_alignBottom="@id/imageview_content"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="20dp" android:src="@drawable/info" android:background="@null"/>


        <View android:id="@+id/view_red_divider" android:layout_width="fill_parent" android:layout_height="4dp" android:background="#990505" android:layout_below="@id/imageview_content"/>

        <WebView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_toLeftOf="@id/view_touchbutton"
                 android:id="@+id/webview" android:layout_below="@id/view_red_divider" android:fitsSystemWindows="true"/>

    </RelativeLayout>
</ScrollView>

<LinearLayout android:id="@+id/layout_splash_screen" android:layout_width="fill_parent" android:layout_height="fill_parent"
              android:gravity="center_horizontal|center_vertical" android:background="#ecece7" android:visibility="gone" >

    <ProgressBar style="?android:attr/progressBarStyleInverse" android:layout_width="wrap_content" android:layout_height="wrap_content"
                 android:indeterminate="true" android:paddingRight="8dp" />
</LinearLayout>

1 个答案:

答案 0 :(得分:1)

将您的RelativeLayout更改为LinearLayout并将 WebView LinearLayout 的权重设置为android:layout_weight="1"