Can I set FLAG_LAYOUT_NO_LIMITS only for status bar?

前端 未结 13 1707
旧时难觅i
旧时难觅i 2020-12-23 13:32

I need to make transparent status bar. I am using getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) and it is make status bar as I want. Bu

13条回答
  •  盖世英雄少女心
    2020-12-23 13:47

    Scroll down to check how the end result looks like

    First of all, define your styles.xml something like this-

    styles.xml

    
    

    DO NOT add the following line

    true

    Adding above line will NOT shift the layout up when the soft keyboard is shown on a Dialog with an EditText

    Then override this style in v21 and v23 styles like this-

    v21/styles.xml

    
    

    v23/styles.xml

    
    

    Activity code - Kotlin

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.setFlags(
                LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                LayoutParams.FLAG_LAYOUT_NO_LIMITS
        )
        setContentView(R.layout.YOUR_LAYOUT_RESOURCE_ID)
        .
        .
    .
    }
    

    Activity code - Java

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(
                LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                LayoutParams.FLAG_LAYOUT_NO_LIMITS
        )
        setContentView(R.layout.YOUR_LAYOUT_RESOURCE_ID)
        .
        .
        .
    }
    

    End result

提交回复
热议问题