Set the background color of only the (1/4) part of the viewport (Android)

Is it possible to set the background color of only the (1/4) th part of the view in Android? I have a use case when I need to select a view and color it, dividing it in parts, Ive looked at the developer’s documents, but I can’t find a way to do the same.

Edit: I need to make it look like "| | | |" and I need to do it dynamically.

+4
source share
3 answers

it is good for you

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#FFFFFF" android:endColor="#00000000" android:angle="45"/> </shape> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/gradient" > </LinearLayout> 
+7
source

You tried to use

  android:drawableTop="@drawable/....." 
0
source

try it

 <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <TextView android:text="red" android:gravity="center_horizontal" android:background="#aa0000" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="green" android:gravity="center_horizontal" android:background="#00aa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="blue" android:gravity="center_horizontal" android:background="#0000aa" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> <TextView android:text="yellow" android:gravity="center_horizontal" android:background="#aaaa00" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1"/> </LinearLayout> 
0
source

Source: https://habr.com/ru/post/1391779/


All Articles