简体   繁体   English

设置透明背景-动作栏

[英]Set transparent background - Action Bar

I'm trying to set the background of the actionbar to be transparent 我正在尝试将操作栏的背景设置为透明

Is it possible? 可能吗? if possible can someone show me how? 如果可能的话,有人可以告诉我如何?

Here are my codes: 这是我的代码:

public class MainMenu extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActionBar actionbar = getSupportActionBar();
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main_menu);
        LinearLayout v = (LinearLayout) findViewById(R.id.layout);
        //v.setBackgroundColor(0xffECECEC);
        v.setBackgroundResource(R.drawable.background);

        actionbar.setDisplayShowTitleEnabled(false);
        actionbar.setDisplayShowHomeEnabled(false);

        LayoutInflater mInflater = LayoutInflater.from(this);
        View mCustomView = mInflater.inflate(R.layout.action, null);
        TextView mTitleTextView = (TextView) mCustomView.findViewById(R.id.actiontitle);
        mTitleTextView.setText("HADI");

        actionbar.setCustomView(mCustomView);
        actionbar.setDisplayShowCustomEnabled(true);

        BitmapDrawable background = new BitmapDrawable (BitmapFactory.decodeResource(getResources(), R.drawable.actionbar)); 
         background.setTileModeX(android.graphics.Shader.TileMode.REPEAT); 

         actionbar.setBackgroundDrawable(background);

    }

通过在操作栏样式中设置Alpha进行修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM