Java Code Examples for android.support.design.widget.AppBarLayout#getLayoutParams()

The following examples show how to use android.support.design.widget.AppBarLayout#getLayoutParams() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PickerActivity.java    From MultiImagePicker with MIT License 6 votes vote down vote up
private void handleToolbarVisibility(final boolean show) {

        final AppBarLayout appBarLayout = (AppBarLayout) mToolbar.getParent();
        final CoordinatorLayout rootLayout = (CoordinatorLayout) appBarLayout.getParent();

        final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
        final AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();

        if (show) {
            //Show appBar
            behavior.setTopAndBottomOffset(0);
            behavior.onNestedPreScroll(rootLayout, appBarLayout, null, 0, 1, new int[2]);

        } else {
            //Hide appBar
            behavior.onNestedFling(rootLayout, appBarLayout, null, 0, 10000, true);
        }

    }
 
Example 2
Source File: MyUtils.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 5 votes vote down vote up
public static void setToolbarOffset(CoordinatorLayout coordinatorLayout, AppBarLayout appBarLayout, int offset) {
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) appBarLayout.getLayoutParams();
    AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) layoutParams.getBehavior();
    if (behavior != null) {
        behavior.setTopAndBottomOffset(offset);
        behavior.onNestedPreScroll(coordinatorLayout, appBarLayout, null, 0, 1, new int[2]);
    }
}
 
Example 3
Source File: ScrollingAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@ReactProp(name = "translucent")
public void setTranslucent(AppBarLayout view, boolean translucent) {
    if (Build.VERSION.SDK_INT >= 21 && translucent) {
        int statusBarHeight = getStatusBarHeight(view.getContext());
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
        params.setMargins(0, statusBarHeight, 0, 0);
    }
}
 
Example 4
Source File: MergedAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 5 votes vote down vote up
@ReactProp(name = "translucent")
public void setTranslucent(AppBarLayout view, boolean translucent) {
    if (Build.VERSION.SDK_INT >= 21 && translucent) {
        int statusBarHeight = getStatusBarHeight(view.getContext());
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
        params.setMargins(0, statusBarHeight, 0, 0);
    }
}
 
Example 5
Source File: MainActivity.java    From Expense-Tracker-App with MIT License 5 votes vote down vote up
private void setNavigationModeStandard() {
    CoordinatorLayout coordinator = (CoordinatorLayout) findViewById(R.id.main_coordinator);
    AppBarLayout appbar = (AppBarLayout) findViewById(R.id.app_bar_layout);
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) appbar.getLayoutParams();
    AppBarLayout.Behavior behavior = (AppBarLayout.Behavior) params.getBehavior();
    if (behavior != null && appbar != null) {
        int[] consumed = new int[2];
        behavior.onNestedPreScroll(coordinator, appbar, null, 0, -1000, consumed);
    }
    mainTabLayout.setVisibility(View.GONE);
}
 
Example 6
Source File: NowPlayingActivity.java    From Rey-MusicPlayer with Apache License 2.0 4 votes vote down vote up
@SuppressLint("RestrictedApi")
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_now_playing_2);

        /**
         *Initialisations
         */
        mFragments = new ArrayList<>();

        mContext = getApplicationContext();
        mApp = (Common) mContext;
        if (mApp.isServiceRunning()) {
            mSongs = mApp.getService().getSongList();
        } else {
            mSongs = mApp.getDBAccessHelper().getQueue();
        }

        mHandler = new Handler();

        mVelocityViewPager = (VelocityViewPager) findViewById(R.id.nowPlayingPlaylistPager);

        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
        getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mToolbar.setNavigationOnClickListener(v -> onBackPressed());

        mAppBarLayout = (AppBarLayout) findViewById(R.id.id_toolbar_container);
        /**
         *Seekbar Related
         */
        mSeekBarIndicatorCardView = (CardView) findViewById(R.id.seekbarIndicatorParent);
        mSeekBarIndicatorTextView = (TextView) findViewById(R.id.seekbarIndicatorText);
        mSeekBar = (SeekBar) findViewById(R.id.nowPlayingSeekBar);


        /**
         *Adding QueueFragment
         */

        mQueueFragmentContainer = (RelativeLayout) findViewById(R.id.queue_fragment_container);
        mNowPlayingContainer = (RelativeLayout) findViewById(R.id.nowPlayingRootContainer);
//
//        if (Configuration.ORIENTATION_LANDSCAPE == getResources().getConfiguration().orientation) {
//            DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
//            int width = (metrics.widthPixels) / 2;
//
//            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mQueueFragmentContainer.getLayoutParams();
//            params.width = width;
//            mQueueFragmentContainer.setLayoutParams(params);
//
//            RelativeLayout.LayoutParams paramss = (RelativeLayout.LayoutParams) mNowPlayingContainer.getLayoutParams();
//            paramss.width = width;
//            mNowPlayingContainer.setLayoutParams(paramss);
//        }

        /**
         *set toolbar height
         */

        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mAppBarLayout.getLayoutParams();
        params.topMargin = Common.getStatusBarHeight(this);
        params.bottomMargin = 0;
        mAppBarLayout.setLayoutParams(params);

        /**
         *All Buttons
         */
        mPlayPauseButtonBackground = (RelativeLayout) findViewById(R.id.playPauseButtonBackground);
        mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
        mNextButton = (ImageButton) findViewById(R.id.nextButton);
        mPreviousButton = (ImageButton) findViewById(R.id.previousButton);
        mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton);
        mRepeatButton = (ImageButton) findViewById(R.id.repeatButton);

        mControlsHolderCardView = (CardView) findViewById(R.id.now_playing_controls_header_parent);

        initViewPager();


        /**
         *Listeners
         */

        mSeekBar.setOnSeekBarChangeListener(onSeekBarChangeListener);
        mPlayPauseButtonBackground.setOnClickListener(onPlayPauseListener);
        mPlayPauseButton.setOnClickListener(onPlayPauseListener);

        mNextButton.setOnClickListener(onNextListener);
        mPreviousButton.setOnClickListener(onPreviousListener);
        mShuffleButton.setOnClickListener(onShuffleListener);
        mRepeatButton.setOnClickListener(onRepeatListener);

        mHandler.postDelayed(() -> animateInControlsBar(), 500);

    }
 
Example 7
Source File: ScrollingAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 4 votes vote down vote up
@ReactProp(name = "height")
public void setHeight(AppBarLayout view, int height) {
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
    params.height = (int) PixelUtil.toPixelFromDIP(height);
    view.setLayoutParams(params);
}
 
Example 8
Source File: MergedAppBarLayoutManager.java    From react-native-bottom-sheet-behavior with MIT License 4 votes vote down vote up
@ReactProp(name = "height")
public void setHeight(AppBarLayout view, int height) {
    CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams();
    params.height = (int) PixelUtil.toPixelFromDIP(height);
    view.setLayoutParams(params);
}