2014-07-05 7 views
0

안녕 얘들 아 Trasparent ActionBar를 설정하고 싶습니다. xml을 편집하려고했지만 작동하지 않습니다. 나는 혼란 스럽다. 이것은Trasparent ActionBar?

<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> 

당신이 날이에 대한 간단한 예 할 수 있습니다 내 Styles.xml입니까? 여기를 참조하십시오 : 나는이 코드를 시도했지만 작동하지 않습니다 http://i.stack.imgur.com/JrrWl.png .. 이클립스

 super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main);  

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); 
    ActionBar actionBar = getActionBar(); 
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff"))); 
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff"))); 

로그 캣이

감사합니다 오류 ... 응용 프로그램 충돌을 표시하지 않습니다!

+0

당신은 전체 화면을 의미? –

+0

참조 http://stackoverflow.com/a/13854832/1091466 –

+0

예 가능할 경우 – user3671540

답변

1

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