[![](https://travis-ci.org/YummyLau/PanelSwitchHelper.svg?branch=master)](https://travis-ci.org/YummyLau/panelSwitchHelper) ![Language](https://img.shields.io/badge/language-java-orange.svg) ![Language](https://img.shields.io/badge/language-kotlin-orange.svg) ![Version](https://img.shields.io/badge/version-1.4.0-blue.svg) ![Size](https://img.shields.io/badge/size-14K-brightgreen.svg) README: [中文文档](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README-zh.md) ### Introduction to the framework When developing a chat/video/live/information interface, users are expected to maintain a smooth transition between the input method and the function panel (such as the expression panel/more options panel, etc.). Investigate the mainstream app effects and implementation in the market, and realize a set of input panel switching framework compatible with multiple scenes. Currently the framework has been tested and used. ### Framework advantages * Improve the traditional technical solution of using `Weight+LinearLayout` to dynamically change the layout height to suit the panel, and support multiple native ViewGroup containers * In pursuit of a smoother adaptation effect, when the input method dynamically adjusts the height or dynamically hides the navigation bar, the function panel can be adapted in real time * In pursuit of a smoother switching effect, the sliding mode is supported, the sliding will be smoother, and the fixed mode is also supported * Rich model adaptation, adapt to non-conventional Phone models such as full screen/bang screen/digging screen/Pad * Rich scene support, support Activity/Fragment/Dialog/PopupWindow, apply to chat/video/live broadcast/stream comment, etc. * Rich API support, customizable content container, business panel, flexible control panel hiding, flexible control of switching panel speed * Support full screen mode, and panel switching can also be handled in FullScreen mode For more details, please refer to * [Introduction to scenario usage](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_SENCE.md) * [API Usage Guide](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_API.md) * [Library version update log](https://github.com/YummyLau/PanelSwitchHelper/blob/master/README_UPDATE.md) Demo content is as follows Download from QR code The Androidx version runs by default. If you need to open non-Androidx, open the app in `Settings.gradle` and close the Androidx configuration in `gradle.properties`. ### Instructions 1. How to 1.1 Add library dependencies in module script `build.gradle` ```groovy allprojects { repositories { maven { url 'https://jitpack.io' } } } ``` 1.2 Add the dependency ```groovy //1.4.0 版本及后续,仅支持 Androidx dependencies { implementation 'com.github.DSAppTeam:PanelSwitchHelper:v1.5.8' } ``` 2. Use the container provided by the framework in the layout file Xml ``` ``` 3. Initialize the PanelSwitchHelper object, and the framework will automatically collect layout information. At the same time, intercept the processing when the return key is adjusted. ``` //Activity scene, initialized in onStart method, others such as Fragment/Dialog/PopupWindow refer to Demo private PanelSwitchHelper mHelper; @Override protected void onStart() { super.onStart(); if (mHelper == null) { mHelper = new PanelSwitchHelper.Builder(this) .addKeyboardStateListener { onKeyboardChange { //Optional implementation, monitor input method changes } } .addEditTextFocusChangeListener { onFocusChange { _, hasFocus -> //Optional implementation, monitor input box focus changes } } .addViewClickListener { onClickBefore { //Optional implementation, listen for trigger clicks } } .addPanelChangeListener { onKeyboard { //Optional implementation, input method display callback } onNone { //Optional implementation, default state callback } onPanel { //Optional implementation, panel display callback } onPanelSizeChange { panelView, _, _, _, width, height -> //Optional implementation, dynamic callback of panel height change caused by input method dynamic adjustment } } .addContentScrollMeasurer { //Optional, in sliding mode, the sliding distance can be customized for the view in the content panel, the default sliding distance is defaultDistance getScrollDistance { defaultDistance -> defaultDistance - 200 } getScrollViewId { R.id.recycler_view } } .addPanelHeightMeasurer { //Optional It is used to set the height of the front panel without obtaining the height of the input method. If it is not set, the height within the frame is the default synchronizeKeyboardHeight { false } getTargetPanelDefaultHeight { DisplayUtils.dip2px(this@DefaultHeightPanelActivity,400f)} getPanelTriggerId { R.id.add_btn } } .logTrack(true) //Optional, default false, whether to enable log information output .build(true) //Optional, default false, whether to open the input method by default } } @Override public void onBackPressed() { //When the user presses the return key, if the panel is displayed, it needs to be hidden if (mHelper != null && mHelper.hookSystemBackForHindPanel()) { return; } super.onBackPressed(); } ``` ### Expectations The project was written only to improve the efficiency of daily development and focus on processing business. If you have better practices or suggestions, please write to yummyl.lau@gmail.com. Or search WeChat "lym_llllll" and add WeChat for feedback. If the framework is helpful to you, Amway can give the partners around you, and every star is an affirmation of the framework.