Android setting LinearLayout background programmatically

后端 未结 6 898
一整个雨季
一整个雨季 2021-02-06 02:34

I have a situation where I need to set a background on a LinearLayout programatically.

In my layout, I am setting my background using `android:background=\"?android:att

6条回答
  •  遇见更好的自我
    2021-02-06 03:30

    You can use something like this

    TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.selectableItemBackgroun d, outValue, true); view.setBackgroundResource(outValue.resourceId);

提交回复
热议问题