【问题标题】:How do I alternate the background color of children within a LinearLayout?如何在 LinearLayout 中交替子项的背景颜色?
【发布时间】:2016-03-03 15:19:01
【问题描述】:

有了一个简短的列表,而不是通过 ListViewRecyclerView,我选择使用 LinearLayout 来手动填充子级。

如何替换这些孩子的背景颜色以在我的 LinearLayout 中获得条纹外观?

【问题讨论】:

  • 您应该能够在子视图上交替设置背景属性:android:background="@color/white", android:background="@color/gray"

标签: java android xml android-layout


【解决方案1】:

您的布局子级通常是 View 类的后代,因此您可以使用

View.setBackroundResources(int);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-06
    • 2011-10-13
    • 2014-06-17
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    • 2010-11-26
    • 1970-01-01
    相关资源
    最近更新 更多