Webview 正在拉伸到全屏

问题描述 投票:0回答:1

我正在尝试将 WebView 配置为放置在 ChipGroup 的下方。我正在为此尝试 ContraintLayout,但我不完全知道我做错了什么,因为 WebView 正在拉伸到全屏,尽管我设置了

Top_toBottomOf
。谢谢

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_activity_color"
    tools:context=".presentation.activities.MainActivity">

    <HorizontalScrollView
        android:id="@+id/horizontal_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="10dp"
        android:layout_marginTop="10dp"
        android:layout_marginEnd="10dp"
        android:scrollbars="none"
        android:theme="@style/Theme.MaterialComponents.Light"
        android:visibility="visible"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <com.google.android.material.chip.ChipGroup
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/chip_group"
            app:chipSpacingHorizontal="15dp"
            app:singleLine="true"
            app:singleSelection="true">

            <com.google.android.material.chip.Chip
                style="@style/CustomStyleChip"
                android:id="@+id/first_chip"
                android:checkable="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/google_name" />

        </com.google.android.material.chip.ChipGroup>
    </HorizontalScrollView>

    <WebView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:id="@+id/webview"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/horizontal_scroll_view"/>
       </androidx.constraintlayout.widget.ConstraintLayout>
android kotlin android-layout android-webview
1个回答
0
投票

试试这个

<WebView
    android:id="@+id/webview"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toBottomOf="@id/horizontal_scroll_view"/>
© www.soinside.com 2019 - 2024. All rights reserved.