FitWindowsLinearLayout.java revision ec3f49d21a507835c1f50ce5600000b587a2af08
1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v7.internal.widget; 18 19import android.content.Context; 20import android.graphics.Rect; 21import android.util.AttributeSet; 22import android.widget.LinearLayout; 23 24/** 25 * @hide 26 */ 27public class FitWindowsLinearLayout extends LinearLayout { 28 29 public interface OnFitSystemWindowsListener { 30 boolean onFitSystemWindows(Rect insets); 31 } 32 33 private OnFitSystemWindowsListener mListener; 34 35 public FitWindowsLinearLayout(Context context) { 36 super(context); 37 } 38 39 public FitWindowsLinearLayout(Context context, AttributeSet attrs) { 40 super(context, attrs); 41 } 42 43 public void setOnFitSystemWindowsListener(OnFitSystemWindowsListener listener) { 44 mListener = listener; 45 } 46 47 @Override 48 protected boolean fitSystemWindows(Rect insets) { 49 if (mListener != null && mListener.onFitSystemWindows(insets)) { 50 return true; 51 } 52 return super.fitSystemWindows(insets); 53 } 54} 55