How do I have an ActionBar icon/logo that overlaps the content as well?

后端 未结 2 500
名媛妹妹
名媛妹妹 2021-01-01 06:25

I\'m currently making one of my very first applications. I\'m using ActionBarSherlock. I would like to make my logo overlap the actionbar (scrollview).

Currently I h

2条回答
  •  不思量自难忘°
    2021-01-01 07:24

    You can either:

    A. Split your image in two
    Have the top part as the ActionBar logo, then show the bottom part over your content.

    B. Use a single image
    You'll need a layout file that contains just your logo (you'll probably want something like an ImageView inside a LinearLayout so you can easily set the correct margins). Then after calling setContentView for your activity, add your logo view with:

    ViewGroup decorViewGroup = (ViewGroup) getWindow().getDecorView();
    decorViewGroup.addView(logoView);
    

    Using a layout file

    Example layout file (logo_view.xml):

    
    
        
    
    
    

    Inflate the layout file:

    LayoutInflater inflater = LayoutInflater.from(this);
    View logoView = inflater.inflate(R.layout.logo_view, null, false);
    

提交回复
热议问题