【问题标题】:trying to add another layout horizontal to my layout vertical but get error message尝试将另一个布局水平添加到我的垂直布局但收到错误消息
【发布时间】:2018-04-25 21:44:09
【问题描述】:

enter image description here

我尝试在垂直布局中创建另一个水平布局,但 android 工作室说我的水平布局没有父级并且没有用,即使我嵌套在垂直布局(父级)中也是如此。我正在尝试为我的计算器创建另一行。

【问题讨论】:

    标签: android-studio layout


    【解决方案1】:

    例如,我只是使用 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-04
      • 1970-01-01
      • 1970-01-01
      • 2017-08-26
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多