android:windowBackground和之间有什么区别android:colorBackground?
例:
<style name = "theme">
<item name ="android:windowBackground">@color/black</item>
<item name ="android:colorBackground">@color/black</item>
</style>
Run Code Online (Sandbox Code Playgroud)
哪一个会影响您在加载新活动时看到的颜色?
我想改变主视图(不是按钮或文本视图)的背景颜色,只是通常是黑色的真实背景...我得到了这段代码:
view.setBackgroundColor(0xfff00000);
Run Code Online (Sandbox Code Playgroud)
这是在里面OnClickListener,但它只是改变了Button的背景.
我怎样才能设置活动的背景颜色setContentView.我有一个活动,需要花费大量的时间来加载,我需要保持背景白色,直到活动完成加载.
我可以通过写入来改变LinearLayout的背景
机器人:背景="@绘制/概述"
到我的LinearLayout.
但是,我无法以编程方式执行此操作.我试过以下:
LinearLayout horizontal_menu = new LinearLayout(this); ... horizontal_menu.setBackgroundResource(getResources().getInteger(R.drawable.overview));
以及代码来源:
horizontal_menu.setBackground(getResources()getDrawable(R.drawable.overview));
第一次尝试在运行时抛出RuntimeException,第二行似乎什么都不做 - >没有错误,没有异常,没有更改背景点击...
- > overview.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:drawable="@color/half_transparent"/>
<item android:state_pressed="true" android:drawable="@color/half_transparent" />
</selector>
Run Code Online (Sandbox Code Playgroud)
我希望有人能帮助我!
谢谢!
编辑:
LinearLayout content = (LinearLayout)findViewById(R.id.LinearLayout);
LinearLayout horizontal_menu = new LinearLayout(this);
horizontal_menu.setOrientation(LinearLayout.HORIZONTAL);
horizontal_menu.setBackgroundResource(getResources().getInteger(R.drawable.overv??iew));
content.addView(horizontal_menu);
Run Code Online (Sandbox Code Playgroud)