How to find the height of the black bar on the Moto 360

I am developing an Android Wear app and the content at the very bottom of the screen is clipping due to the black bar.

This video says that we should get the bar height like this:

@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
   int barHeight = insets.getSystemWindowInsetBottom();
}

      

but actually barHeight is always 0.

Now I'm hacking it

if (Build.MODEL.equals("Moto 360")) {

}

      

but this is not a very secure future. Any hints?

+3


source to share


1 answer


I am using window inserts to define chin height in Activity of Wear app and in Face Watch engine, so it works. I tested Moto 360. This is an excerpt from Activity:



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            stub.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
                @Override
                public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                    int chinHeight = insets.getSystemWindowInsetBottom();
                    // chinHeight = 30;
                    return insets;
                }
            });
        }
    });
}

      

+1


source







All Articles