Error in xml file on Android app

Asked 2 years ago, Updated 2 years ago, 80 views

I'm in trouble because I can't fix the red wave line error in the code.
<TabHost

in the section This view is not constrained vertically. At runtime it will jump to the left unless you add a vertical constraint

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
    tools:context="com.example.a100527.myapplication.MainActivity"
    android:background="@drawable/yado_haitta">

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="200dp"
        android:layout_height="345dp"
        tools:layout_editor_absoluteX="5dp"
        tools:layout_editor_absoluteY="5dp"
        app:layout_constrainLeft_toLeftOf="parent"
        app:layout_constrainRight_toRightOf="parent">

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

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            tools:layout_editor_absoluteX="5dp"
            tools:layout_editor_absoluteY="5dp"/>


        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

            <LinearLayout
                android: id="@+id/right"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="@drawable/unnamed"
                android: orientation="vertical"

                app:layout_constrainLeft_toLeftOf="@+id/main">

            </LinearLayout>

            <LinearLayout
                android: id="@+id/left"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/unnamed"
                android: orientation="vertical"
                app:layout_constrainRight_toRightOf="@+id/main">

            </LinearLayout>

            <LinearLayout
                android: id="@+id/main"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/unnamed"
                android: orientation="vertical">

            </LinearLayout>

    </LinearLayout>
    </TabHost>
</android.support.constraint.ConstraintLayout>

That's the code.

android xml

2022-09-30 21:27

1 Answers

If you add the following line to the TabHost attribute value, it will work.

app:layout_constrainTop_toTopOf="parent"


2022-09-30 21:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.