пытаюсь добавить другой макет по горизонтали в мой макет по вертикали, но получаю сообщение об ошибке - PullRequest
0 голосов
/ 26 апреля 2018

введите описание изображения здесь

Я пытался создать еще один горизонтальный макет внутри вертикального макета, но андроид-студии говорят, что мой горизонтальный макет не имеет родителя и не имеет смысла, даже после того, как я вложил в негомой макет вертикальный (родитель).Я пытаюсь создать еще одну строку для своего калькулятора.

1 Ответ

0 голосов
/ 26 апреля 2018

Я просто использую TextView, например, но я использую это все время, и это работает без проблем.

Убедитесь, что вы объявили пространство имен xml в родительском макете.

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>
</LinearLayout>
...