活动主题与应用程序的其他活动不同

时间:2014-06-02 09:38:55

标签: android android-theme

您好我正在开发一个Android应用程序。我在应用程序中执行网络操作时显示ProgressDialog。但ProgressDialog的主题在不同的活动中显得不同。

<activity
    android:name="teemwurk.android.ClockActivity"
     android:label="@string/title_activity_clock"
     android:screenOrientation="portrait"
     android:theme="@style/CustomTheme" >
</activity>

customtheme.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CustomTheme" parent="android:Theme">
        <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground </item>
        <item name="android:windowTitleSize">60dp</item>
    </style>

    <style name="WindowTitleBackground">
        <item name="android:padding">0px</item>
        <item name="android:background">#F3F8FB</item>
    </style>

</resources>

ClockActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // requesting to set
                                                        // the custom title
                                                        // bar
    setContentView(R.layout.activity_clock);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
            R.layout.custom_title);

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment()).commit();
    }

    // set the back button on click listener
    ((TextView)findViewById(R.id.backTextView)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });
}

TeemWurkAsyncTask.java

public class TeemWurkAsyncTask extends AsyncTask<String, Void, String> {

    private ProgressDialog mProgressDialog;
    private Context mContext;
    private TaskCompleteListener taskCompleteListener;
    private int method;
    private String TAG = "TeemWurkAsyncTask";

    public TeemWurkAsyncTask(TaskCompleteListener taskCompleteListener, int method, Context mContext) {
        this.taskCompleteListener = taskCompleteListener;
        this.method = method;
        this.mContext = mContext;
    }

    @Override
    protected void onPreExecute() {
        // display the progress dialog
        mProgressDialog = new ProgressDialog(mContext);
        mProgressDialog.setTitle(mContext.getString(R.string.app_name));
        mProgressDialog.setMessage(mContext.getString(R.string.please_wait));
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.show();
    }

enter image description here

但我希望它看起来应该低于此ProgressDialog

enter image description here

提前致谢。

2 个答案:

答案 0 :(得分:1)

试试这个。你应该改变这个

<style name="CustomTheme" parent="android:Theme">
    ........
</style>

<style name="CustomTheme" parent="@android:Theme.Holo.Light">
   ........
</style>

答案 1 :(得分:0)

试试这个..

改变这个..

<style name="CustomTheme" parent="android:Theme">

<style name="CustomTheme" parent="@style/AppTheme">

修改

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CustomTheme" parent="@style/AppTheme">
        <item name="newStyle">@style/CustomThemeStyle</item>            
    </style>
    <style name="CustomThemeStyle" parent="android:Theme">
        <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground </item>
        <item name="android:windowTitleSize">60dp</item>
        <item name="android:windowActionBar">false</item>
    </style>
    <style name="WindowTitleBackground">
        <item name="android:padding">0px</item>
        <item name="android:background">#F3F8FB</item>
    </style>

</resources>

修改

<?xml version="1.0" encoding="utf-8"?>
<resources>
     <attr name="newStyle" format="reference" />
</resources>