android - LinearLayout 和 Webview 在 ScrollVIew 中的大小不一样

标签 android webview scrollview

我有以下 View 树:

  • 相对布局
    • ScrollView
      • 相对布局
        • WebView
        • 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>

最佳答案

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

关于android - LinearLayout 和 Webview 在 ScrollVIew 中的大小不一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12282858/

相关文章:

android - 设备独立像素与缩放独立像素

JavaFX Webview 编码错误

android - ScrollView 在内部 3 个 recyclerviews 中滚动不流畅

javascript - Android 将未知字符串传递给 javascript

ios - 基于动态内容的webView高度约束

c# - ScrollViewer.ChangeView 处于事件状态时触摸屏幕会破坏应用程序 UWP

android - 为什么滚动 listView 时项目会消失?

Android ViewPager 和从网络加载图像

java - 无法将空值放入 JSON 对象

android - 从 ActionBarSherlock 迁移到 ActionBarCompat 时有哪些常见问题?