如何在两个相同的片段上划分活动,当你在Android中拥有WebView时?

时间:2018-03-22 12:05:59

标签: android xml webview

我有一个活动和两个碎片。我想将它们放在另一个活动中,我需要它们的高度,它们都是一样的。但是当我尝试时,总是用webView片段变小,然后另一个。我不想在dp或px中设置WebView的高度。

这是我的xml代码。

activity_object_detail_info.xml

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/appBar"
            android:theme="@style/AppTheme.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:layout_height="wrap_content"
                android:layout_width="match_parent">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="horizontal">

                    <Button
                        android:layout_width="24dp"
                        android:layout_height="24dp"
                        android:id="@+id/back_buttonObject"
                        android:background="@drawable/ic_arrow_back_white_24dp"/>

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="30dp"
                        android:orientation="horizontal"
                        android:layout_gravity="center_vertical|center_horizontal"
                        android:gravity = "center_vertical|center_horizontal"
                        android:layout_weight="1">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="match_parent"
                            android:text="@string/object"
                            android:textColor="@color/white"
                            android:id="@+id/toolbar_titleObject"
                            android:textSize="24dp" />

                    </LinearLayout>

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:id="@+id/arrowDownA"
                        android:src="@drawable/arrow_down"
                        android:layout_marginRight="10dp"/>

                    <ImageView
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:id="@+id/arrowUpA"
                        android:src="@drawable/arrow_up"
                        android:layout_marginRight="5dp"/>

                </LinearLayout>

            </android.support.v7.widget.Toolbar>

        </android.support.design.widget.AppBarLayout>

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/objectMap"
                android:layout_weight="1"/>

            <FrameLayout
                android:id="@+id/objectContent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"/>

        </LinearLayout>
    </LinearLayout>

</android.support.design.widget.CoordinatorLayout>

fragment_map_object.xml

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


    <LinearLayout
        android:id="@+id/webViewLL"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <WebView
                android:id="@+id/webviewMapOdject"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

            <Button
                android:id="@+id/cleanLayersObject"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="52dp"
                android:layout_height="52dp"
                android:background="@drawable/clean"
                android:singleLine="false"
                android:layout_gravity="end"
                android:layout_marginTop="70dp"
                android:layout_marginRight="10dp"/>

        </FrameLayout>

    </LinearLayout>

</LinearLayout>

fragment_content_object.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto">

    <android.support.design.widget.TabLayout
        android:id="@+id/result_tabs"
        android:background="@color/colorPrimary"
        app:tabSelectedTextColor="@color/white"
        app:tabIndicatorColor="@color/white"
        app:tabTextColor="@color/white"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabMode="scrollable"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</LinearLayout>

请帮忙吗?

1 个答案:

答案 0 :(得分:1)

请在activity_object_detail_info.xml文件中更新以下代码。

<LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/objectMap"
                android:layout_weight="1"/>

            <FrameLayout
                android:id="@+id/objectContent"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"/>

        </LinearLayout>