Coloring the Space widget

I am trying to color the Space widget. I tried using the android:foreground and android:background attributes, but still it displays a transparent view.

  <android.support.v4.widget.Space android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:foreground="@android:color/black" android:background="@android:color/black" /> 
+8
android android-layout android-widget space
source share
2 answers

According to official documents definition:

Simple is a lightweight subclass of View that can be used to create gaps between components in general layouts.

They probably did not think about the "coloring of empty space."
Where "empty" means "without color," "invisible."

What would I do:

 <View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@android:color/black" /> 

Using the bare view as a separator is one of my favorite 2/3 tricks with bare views.
I also use them as separators and as a β€œcenter point” in RelativeLayouts.

+23
source share

I tried the "look" trick, but had a horizontal / vertical constraint problem with GridLayout (and at runtime, the drawing stops as soon as this view is encountered). For me (Studio 2.3.3, api 21) this worked:

 <TextView android:layout_width="4dp" android:layout_height="match_parent" android:layout_gravity="fill_vertical" android:background="@color/housetoolsBlue" /> 
0
source share

All Articles