Custom title bar without padding (Android)

后端 未结 7 701
失恋的感觉
失恋的感觉 2020-11-30 07:39

So I am using the techniques in this thread to use a custom background for my titlebar. Unfortunately the framework places my layout inside a FrameLayout (

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 08:37

    I got rid of the padding by getting the title container and setting the padding to 0. It works on Android 4.

    titleContainerId = (Integer)Class.forName("com.android.internal.R$id").getField("title_container").get(null);
    
    ViewGroup vg = ((ViewGroup) getWindow().findViewById(titleContainerId));
    vg.setPadding(0, 0, 0, 0);
    

提交回复
热议问题