Android 透明操作栏?

Android 透明操作栏?,android,Android,我要设置透明的ActionBar。 我尝试过编辑xml,但不起作用。我很困惑。 这是my Styles.xml <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="

我要设置透明的ActionBar。 我尝试过编辑xml,但不起作用。我很困惑。 这是my Styles.xml

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

Eclipse中的Logcat未显示错误。。。应用程序崩溃

您需要在
setContentView
之前执行,而不是在它之后执行,否则您将得到一个错误

解决方案:

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#000000ff")));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#000000ff")));
    setContentView(R.layout.activity_main); //do it before this

看到这个Trasparent还是全屏?
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#000000ff")));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#000000ff")));
    setContentView(R.layout.activity_main); //do it before this