Change background of LinearLayout in Android

前端 未结 6 1595
轻奢々
轻奢々 2020-12-24 00:54

I am working on an Android application. I want to change the background of a LinearLayout element.

What attribute can I set in order to change its background?

6条回答
  •  不思量自难忘°
    2020-12-24 01:19

    If you want to set through xml using android's default color codes, then you need to do as below:

    android:background="@android:color/white"
    

    If you have colors specified in your project's colors.xml, then use:

    android:background="@color/white"
    

    If you want to do programmatically, then do:

    linearlayout.setBackgroundColor(Color.WHITE);
    

提交回复
热议问题