HShams
HShams

Reputation: 23

Nested LinearLayout not visible

I'm trying to achieve the following view:

Here's an image of what I want to achieve

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>

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?

Upvotes: 1

Views: 104

Answers (1)

Matthew Shearer
Matthew Shearer

Reputation: 2795

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

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

Upvotes: 5

Related Questions