仅在视图(1/4)部分设置背景颜色(Android)(Set Background color in only (1/4)th portion of a View (Android))

编程入门 行业动态 更新时间:2024-10-28 05:24:44
仅在视图(1/4)部分设置背景颜色(Android)(Set Background color in only (1/4)th portion of a View (Android))

是否可以在Android中仅为(1/4)部分设置背景颜色? 我有一个用例,我需要选择一个视图并在分割后将其着色,我看过开发人员文档,但我无法找到一种方法来做同样的事情。

编辑:我需要把它变成“| | | |”之类的东西 我需要动态地做。

Is it possible to set background color for only (1/4)th portion of a View in Android? I have a use case where I need to select a view and color it after dividing it in portions, Ive looked at developer docs but I am unable to find a way to do the same.

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

最满意答案

它对你有用

<?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>

it is useful 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>

更多推荐

本文发布于:2023-04-28 14:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1332455.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   颜色   背景   Android   Set

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!