嵌套的LinearLayout不可见 [英] Nested LinearLayout not visible

查看:54
本文介绍了嵌套的LinearLayout不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现以下观点:

I'm trying to achieve the following view:

我正在使用以下XML:

I'm using the following XML:

<LinearLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:layout_marginTop="15dp"
  android:layout_gravity="center">

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

      <TextView
          android:id="@+id/tvBedrooms"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:layout_gravity="center"
          tools:text="Bedrooms"
          android:textSize="24sp" />
      <LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          >

          <Button
              android:id="@+id/button_minus"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              tools:text="-"
              android:textStyle="bold"
              android:textSize="24sp"
              android:textColor="@color/colorAccent"
              style="?android:attr/borderlessButtonStyle"
              />

          <TextView
              android:id="@+id/tvValueBed"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:layout_gravity="center"
              tools:text="0"
              android:textSize="24sp"
              />

          <Button
              android:id="@+id/button_plus"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              tools:text="+"
              android:textStyle="bold"
              android:textSize="24sp"
              android:textColor="@color/colorAccent"
              style="?android:attr/borderlessButtonStyle"
              />
      </LinearLayout>
  </LinearLayout>

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

      <TextView
          android:id="@+id/tvBathrooms"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:layout_gravity="center"
          tools:text="Bathrooms"
          android:textSize="24sp" />
      <LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="horizontal"
          >

          <Button
              android:id="@+id/button_minusBath"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              tools:text="-"
              android:textStyle="bold"
              android:textSize="24sp"
              android:textColor="@color/colorAccent"
              style="?android:attr/borderlessButtonStyle"
              />

          <TextView
              android:id="@+id/tvValueBath"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="center"
              android:layout_gravity="center"
              tools:text="0"
              android:textSize="24sp"
              />

          <Button
              android:id="@+id/button_plusBath"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              tools:text="+"
              android:textStyle="bold"
              android:textSize="24sp"
              android:textColor="@color/colorAccent"
              style="?android:attr/borderlessButtonStyle"
              />
      </LinearLayout>
  </LinearLayout>
</LinearLayout>

问题是此XML在运行时不可见.整个水平LinearLayout不可见.它占据了空间,但不可见.我在这里想念什么?

The problem is this XML is not visible at runtime. The whole horizontal LinearLayout is not visible. It occupies the space but it's not visible. What am I missing here?

推荐答案

您正在使用工具"名称空间.这对于设置可以通过IDE查看的属性很有用.

you are using the "tools" namespace. This is useful for setting attributes which you can view through the IDE.

但是.在运行时,这些将为空白.将工具"切换为"android",然后重试.

however. At runtime these will be blank. Switch "tools" to "android" and try again.

这篇关于嵌套的LinearLayout不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆