0

我有使用 eclipse New-->other--> Android Activity --> New Login Activity 创建的标准登录活动

(您可以尝试创建相同的活动......我正在使用“Eclipse 版本:Juno Service Release 1”)

我更改了所有后台活动/片段:#0099cc

但是当我从一个活动传递到另一个活动时,我会看到图像中的背景白色。

你能帮助我吗?

我认为重要的代码如下:

显示进度(真);

    /**
 * Shows the progress UI and hides the login form.
 */

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) {
    // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
    // for very easy animations. If available, use these APIs to fade-in
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

        mLoginStatusView.setVisibility(View.VISIBLE);

                    **I tried in this way**
        mLoginStatusView.setBackgroundColor(Color.parseColor("#0099cc"));
        mLoginStatusView.animate().setDuration(shortAnimTime).alpha(show ?1 : 0).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
                        mLoginStatusView.setVisibility(show? View.VISIBLE : View.GONE); }
        });
        mLoginFormView.setVisibility(View.VISIBLE);
        mLoginFormView.animate().setDuration(shortAnimTime).alpha(show ? 0:1).setListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            mLoginFormView.setVisibility(show ? View.GONE:View.VISIBLE);
        }
                });
    } else {
        // The ViewPropertyAnimator APIs are not available, so simply show
        // and hide the relevant UI components.
        mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
        mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
    }
}

在 login.xml 布局中

        <ProgressBar
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:background="#0099cc" />

在 attrs.xml

<!--
     Declare custom theme attributes that allow changing which styles are
     used for button bars depending on the API level.
     ?android:attr/buttonBarStyle is new as of API 11 so this is
     necessary to support previous API levels.
-->
<declare-styleable name="ButtonBarContainerTheme">
    <attr name="buttonBarStyle" format="reference" />
    <attr name="buttonBarButtonStyle" format="reference" />
</declare-styleable>

记录活动

我想在哪里改变背景

4

2 回答 2

0

我认为您需要为整个应用程序编写自己的样式,这里是 Google 的 API 指南。

于 2013-02-19T14:09:57.370 回答
0

我解决了我的问题(在尝试以多种方式管理样式之后)添加了一个简单的行:

getWindow().getDecorView().setBackgroundColor(Color.parseColor("#0099cc"));

    /**
     * Shows the progress UI and hides the login form.
     */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) {
    // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
    // for very easy animations. If available, use these APIs to fade-in
    // the progress spinner.

    getWindow().getDecorView().setBackgroundColor(Color.parseColor("#0099cc"));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        ...
于 2013-02-19T16:25:05.490 回答