Search in sources :

Example 26 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project StatusBarUtil by laobie.

the class StatusBarUtil method setColorForSwipeBack.

/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {

                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 27 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project MaterialLibrary by DeveloperPaul123.

the class BaseFabListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    coordinatorLayout = new CoordinatorLayout(this);
    coordinatorLayout.setLayoutParams(params);
    CoordinatorLayout.LayoutParams coorLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    coorLayoutParams.setBehavior(new MaterialFabDefaultBehavior());
    coorLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    materialFloatingActionButton = new MaterialFloatingActionButton(this);
    materialFloatingActionButton.setLayoutParams(coorLayoutParams);
    coordinatorLayout.addView(materialFloatingActionButton);
    getHomeLayout().addView(coordinatorLayout);
    ScrollListener scrollListener = new ScrollListener();
    scrollListener.setListView(getListView());
    scrollListener.setScrollThreshold(getResources().getDimensionPixelOffset(R.dimen.material_library_scroll_threshold));
    getListView().setOnScrollListener(scrollListener);
    materialFloatingActionButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onActionButtonClicked();
        }
    });
    isShowing = true;
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MaterialFabDefaultBehavior(com.devpaul.materiallibrary.behaviors.MaterialFabDefaultBehavior) FrameLayout(android.widget.FrameLayout) MaterialFloatingActionButton(com.devpaul.materiallibrary.views.MaterialFloatingActionButton) AbstractScrollListener(com.devpaul.materiallibrary.abstracts.AbstractScrollListener) View(android.view.View)

Example 28 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project CustomViews by AndroidStudy233.

the class CustomBehaviorAct22 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bottomsheet_behavior);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_bottom_behavior);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(" ");
    }
    /**
     * If we want to listen for states callback
     */
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorlayout);
    View bottomSheet = coordinatorLayout.findViewById(R.id.bottom_sheet);
    final BottomSheetBehaviorGoogleMapsLike behavior = BottomSheetBehaviorGoogleMapsLike.from(bottomSheet);
    behavior.addBottomSheetCallback(new BottomSheetBehaviorGoogleMapsLike.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            switch(newState) {
                case BottomSheetBehaviorGoogleMapsLike.STATE_COLLAPSED:
                    Log.d("bottomsheet-", "STATE_COLLAPSED");
                    break;
                case BottomSheetBehaviorGoogleMapsLike.STATE_DRAGGING:
                    Log.d("bottomsheet-", "STATE_DRAGGING");
                    break;
                case BottomSheetBehaviorGoogleMapsLike.STATE_EXPANDED:
                    Log.d("bottomsheet-", "STATE_EXPANDED");
                    break;
                case BottomSheetBehaviorGoogleMapsLike.STATE_ANCHOR_POINT:
                    Log.d("bottomsheet-", "STATE_ANCHOR_POINT");
                    break;
                case BottomSheetBehaviorGoogleMapsLike.STATE_HIDDEN:
                    Log.d("bottomsheet-", "STATE_HIDDEN");
                    break;
                default:
                    Log.d("bottomsheet-", "STATE_SETTLING");
                    break;
            }
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
        }
    });
    AppBarLayout mergedAppBarLayout = (AppBarLayout) findViewById(R.id.merged_appbarlayout);
    MergedAppBarLayoutBehavior mergedAppBarLayoutBehavior = MergedAppBarLayoutBehavior.from(mergedAppBarLayout);
    mergedAppBarLayoutBehavior.setToolbarTitle("Title Dummy");
    mergedAppBarLayoutBehavior.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            behavior.setState(BottomSheetBehaviorGoogleMapsLike.STATE_COLLAPSED);
        }
    });
    bottomSheetTextView = (TextView) bottomSheet.findViewById(R.id.bottom_sheet_title);
    NormalImagePagerAdapter adapter = new NormalImagePagerAdapter(this, mDrawables);
    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(adapter);
    behavior.setState(BottomSheetBehaviorGoogleMapsLike.STATE_ANCHOR_POINT);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return;
    Window window = getWindow();
    // 清除状态栏半透明
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    // 状态栏全透明
    window.setStatusBarColor(Color.RED);
}
Also used : Window(android.view.Window) BottomSheetBehaviorGoogleMapsLike(com.shiqkuangsan.mycustomviews.ui.custom.behavior.BottomSheetBehaviorGoogleMapsLike) TextView(android.widget.TextView) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MergedAppBarLayoutBehavior(com.shiqkuangsan.mycustomviews.ui.custom.behavior.MergedAppBarLayoutBehavior) NormalImagePagerAdapter(com.shiqkuangsan.mycustomviews.adapter.NormalImagePagerAdapter) AppBarLayout(android.support.design.widget.AppBarLayout) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 29 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project ShelterApp by farzamtn.

the class MapsMasterActivity method newPopup.

/**
 * Event handler for FAB which filters the pins displayed on the map. - Farzam
 *
 * @param view the current view
 */
public void newPopup(View view) {
    // instantiate the maps_master_popup.xml layout file
    LayoutInflater layoutInflater = (LayoutInflater) MapsMasterActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    assert layoutInflater != null;
    View customView = layoutInflater.inflate(R.layout.maps_master_popup, null);
    men_checkbox = customView.findViewById(R.id.men_checkbox);
    women_checkbox = customView.findViewById(R.id.women_checkbox);
    youngAdult_checkbox = customView.findViewById(R.id.youngAdult_checkbox);
    children_checkbox = customView.findViewById(R.id.children_checkbox);
    families_checkbox = customView.findViewById(R.id.families_checkbox);
    veterans_checkbox = customView.findViewById(R.id.veterans_checkbox);
    Button closePopupBtn = customView.findViewById(R.id.closePopupBtn);
    Button resetBtn = customView.findViewById(R.id.resetBtn);
    // Retrieving saved instances of checkedboxes
    SharedPreferences sp = getSharedPreferences("Men Check Boxes", MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    men_checkbox.setChecked(sp.getBoolean("men check", false));
    women_checkbox.setChecked(sp.getBoolean("women check", false));
    youngAdult_checkbox.setChecked(sp.getBoolean("young adult check", false));
    children_checkbox.setChecked(sp.getBoolean("children check", false));
    families_checkbox.setChecked(sp.getBoolean("families check", false));
    veterans_checkbox.setChecked(sp.getBoolean("veterans check", false));
    // instantiate popup window
    popupWindow = new PopupWindow(customView, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    popupWindow.setOutsideTouchable(false);
    popupWindow.setFocusable(true);
    CoordinatorLayout c = findViewById(R.id.coordinatorLayout);
    // display the popup window
    popupWindow.showAtLocation(c, Gravity.CENTER, 0, 0);
    // set filter and close the popupwindow
    closePopupBtn.setOnClickListener(v -> {
        // Saving checkbox instances
        editor.putBoolean("men check", men_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("women check", women_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("young adult check", youngAdult_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("children check", children_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("families check", families_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("veterans check", veterans_checkbox.isChecked());
        editor.apply();
        // If all filters all selected show everything
        if (!(men_checkbox.isChecked() && women_checkbox.isChecked() && youngAdult_checkbox.isChecked() && children_checkbox.isChecked() && families_checkbox.isChecked() && veterans_checkbox.isChecked())) {
            for (Marker m : markers) {
                m.setVisible(true);
            }
        }
        // Making sure at least one filter is selected
        if (men_checkbox.isChecked() || women_checkbox.isChecked() || youngAdult_checkbox.isChecked() || children_checkbox.isChecked() || families_checkbox.isChecked() || veterans_checkbox.isChecked()) {
            for (Marker m : markers) {
                m.setVisible(false);
                ShelterData s = model.findItemByName(m.getTitle());
                assert s != null;
                String restrictions = s.getRestrictions().trim().toLowerCase();
                // Displaying shelters with no restrictions for all filters
                if ("anyone".equals(restrictions) || "no restrictions".equals(restrictions)) {
                    m.setVisible(true);
                }
                if (men_checkbox.isChecked()) {
                    if ("men".equals(restrictions)) {
                        m.setVisible(true);
                    }
                }
                if (women_checkbox.isChecked()) {
                    if (restrictions.contains("women")) {
                        m.setVisible(true);
                    }
                }
                if (youngAdult_checkbox.isChecked()) {
                    if ("young adults".equals(s.getRestrictions().toLowerCase())) {
                        m.setVisible(true);
                    }
                }
                if (children_checkbox.isChecked()) {
                    if (restrictions.contains("children")) {
                        m.setVisible(true);
                    }
                }
                if (families_checkbox.isChecked()) {
                    if (restrictions.contains("famil")) {
                        m.setVisible(true);
                    }
                }
                if (veterans_checkbox.isChecked()) {
                    if ("veterans".equals(restrictions)) {
                        m.setVisible(true);
                    }
                }
            }
        }
        popupWindow.dismiss();
    });
    // show all markers again and close the popupwindow
    resetBtn.setOnClickListener(view1 -> {
        for (Marker m : markers) {
            m.setVisible(true);
        }
        // Move camera to GT (DEFAULT) coordinates - Added by Farzam
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mDefaultLocation, DEFAULT_ZOOM));
        // Clearing all check boxes and their saved instances
        men_checkbox.setChecked(false);
        women_checkbox.setChecked(false);
        youngAdult_checkbox.setChecked(false);
        children_checkbox.setChecked(false);
        families_checkbox.setChecked(false);
        veterans_checkbox.setChecked(false);
        editor.putBoolean("men check", men_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("women check", women_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("young adult check", youngAdult_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("children check", children_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("families check", families_checkbox.isChecked());
        editor.apply();
        editor.putBoolean("veterans check", veterans_checkbox.isChecked());
        editor.apply();
        popupWindow.dismiss();
    });
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ShelterData(com.CS2340.shelterapp.Model.ShelterData) Button(android.widget.Button) SharedPreferences(android.content.SharedPreferences) LayoutInflater(android.view.LayoutInflater) PopupWindow(android.widget.PopupWindow) Marker(com.google.android.gms.maps.model.Marker) NavigationView(android.support.design.widget.NavigationView) View(android.view.View)

Example 30 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project PainlessMusicPlayer by Doctoror.

the class CoordinatorLayoutUtil method clearAnchorGravityAndApplyMargins.

public static void clearAnchorGravityAndApplyMargins(@NonNull final View view) {
    final ViewGroup parent = (ViewGroup) view.getParent();
    if (parent instanceof CoordinatorLayout) {
        final Rect rect = new Rect();
        parent.getChildVisibleRect(view, rect, null);
        final ViewGroup.LayoutParams lp = view.getLayoutParams();
        if (lp instanceof CoordinatorLayout.LayoutParams) {
            ((CoordinatorLayout.LayoutParams) lp).anchorGravity = 0;
            ((CoordinatorLayout.LayoutParams) lp).setAnchorId(0);
            ((CoordinatorLayout.LayoutParams) lp).setMargins(rect.left, rect.top, ((CoordinatorLayout.LayoutParams) lp).rightMargin, ((CoordinatorLayout.LayoutParams) lp).bottomMargin);
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup)

Aggregations

CoordinatorLayout (android.support.design.widget.CoordinatorLayout)57 View (android.view.View)37 AppBarLayout (android.support.design.widget.AppBarLayout)17 TextView (android.widget.TextView)15 ViewGroup (android.view.ViewGroup)13 RecyclerView (android.support.v7.widget.RecyclerView)12 Intent (android.content.Intent)9 Toolbar (android.support.v7.widget.Toolbar)8 Snackbar (android.support.design.widget.Snackbar)7 ViewParent (android.view.ViewParent)7 ImageView (android.widget.ImageView)7 NavigationView (android.support.design.widget.NavigationView)5 ViewPager (android.support.v4.view.ViewPager)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 SearchView (android.support.v7.widget.SearchView)5 LayoutInflater (android.view.LayoutInflater)5 FrameLayout (android.widget.FrameLayout)5 TabLayout (android.support.design.widget.TabLayout)4 PagerAdapter (android.support.v4.view.PagerAdapter)4 NestedScrollView (android.support.v4.widget.NestedScrollView)4