DSAppTeam / PanelSwitchHelper

:heavy_check_mark: A framework that helps the keyboard smoothly transition to the function panel 一个帮助键盘平稳过渡到功能面板的框架,支持动画无缝衔接,支持 activity/fragment/dialog/dialogFragment/popupWindow 容器,支持IM/直播/视频播放/信息流评论等场景,支持全屏模式。
Apache License 2.0
2.38k stars 284 forks source link

直接打开表情或者Addition会导致面板空白 #92

Closed KennenH closed 4 years ago

KennenH commented 4 years ago

在所有面板被隐藏的情况下直接打开表情或者Addition就会空白,先打开键盘或者在有一个面板打开的情况下打开另一个面板就会正常是什么原因呢

YummyLau commented 4 years ago

@TinyCaviar 提供版本和log。面板可以设置默认宽高,参考demo。

KennenH commented 4 years ago

Androidx版本:是 PanelSwitchHelper版本:v1.3.8 手机型号: vivo Y31 手机系统版本: Android 5.0

Log D/LogTracker: PanelSwitchLayout(1008400035)#onLayout => getCompatPanelHeight :438 PanelSwitchLayout(1008400035)#onLayout => getContentContainerTop :-438 PanelSwitchLayout(1008400035)#onLayout => onLayout(changed : false , l : 0 , t : 84 , r : 540 , b : 926) ===================&&&&================= PanelSwitchLayout(1008400035)#onLayout => 当前状态 :显示面板输入 PanelSwitchLayout(1008400035)#onLayout => 是否是全屏 :false PanelSwitchLayout(1008400035)#onLayout => 是否是pad机型 :false PanelSwitchLayout(1008400035)#onLayout => 是否显示导航栏 :false PanelSwitchLayout(1008400035)#onLayout => 是否是竖屏 :true PanelSwitchLayout(1008400035)#onLayout => 界面高度(包含系统UI) :960 PanelSwitchLayout(1008400035)#onLayout => 界面高度(不包含系统UI,无论导航栏显示与否) :960 PanelSwitchLayout(1008400035)#onLayout => 界面高度(不包含系统UI,动态计算) :926 PanelSwitchLayout(1008400035)#onLayout => toolbar高度 :0 PanelSwitchLayout(1008400035)#onLayout => StatusBar高度 :34 PanelSwitchLayout(1008400035)#onLayout => NavigationBar高度 :72 PanelSwitchLayout(1008400035)#onLayout => PanelSwitchLayout 绘制起点 :(0,118) PanelSwitchLayout(1008400035)#onLayout => PanelSwitchLayout paddingTop :0 PanelSwitchLayout(1008400035)#onLayout => 输入法高度 :438 D/LogTracker: PanelSwitchLayout(1008400035)#onLayout => 内容容器 top :-438 PanelSwitchLayout(1008400035)#onLayout => 内容容器 高度 :842 PanelSwitchLayout(1008400035)#onLayout => 面板容器 top :404 PanelSwitchLayout(1008400035)#onLayout => 面板容器 高度 438 PanelSwitchLayout(1008400035)#onLayout => changeBounds : true PanelSwitchLayout(1008400035)#onLayout => reverseResetState : true PanelSwitchLayout#onLayout => ContentScrollMeasurer(id 2131296829 , defaultScrollHeight 438 , scrollDistance 438 reset false) origin (l 0,t 0,r 0, b 763) PanelSwitchLayout#onLayout => ContentScrollMeasurer(id 2131296829 , defaultScrollHeight 438 , scrollDistance 438 reset false) layout parent(l 0,t -438,r 540,b 404) self(l 0,t 0,r 540, b763) PanelSwitchLayout(1008400035)#onLayout => layout参数 contentContainer : height - 842 PanelSwitchLayout(1008400035)#onLayout => layout参数 contentContainer : l : 0 t : -438 r : 540 b : 404 D/LogTracker: PanelSwitchLayout(1008400035)#onLayout => layout参数 panelContainerTop : height - 438 PanelSwitchLayout(1008400035)#onLayout => layout参数 panelContainer : l : 0 : 404 r : 540 b : 842 PanelSwitchLayout(1008400035)#onGlobalLayout =>
PanelSwitchLayout(1008400035)#onGlobalLayout => 容器是否可见(true) PanelSwitchLayout(1008400035)#onGlobalLayout => screenHeight is : 960 PanelSwitchLayout(1008400035)#onGlobalLayout => contentHeight is : 926 PanelSwitchLayout(1008400035)#onGlobalLayout => isFullScreen (false) PanelSwitchLayout(1008400035)#onGlobalLayout => navigationBarShown is : false PanelSwitchLayout(1008400035)#onGlobalLayout => 设备 statusBarH : 34,navigationBarH : 72 PanelSwitchLayout(1008400035)#onGlobalLayout => 当前界面 statusBarH : 34, navigationBarH : 0 全面屏手势虚拟栏H : 0 PanelSwitchLayout(1008400035)#onGlobalLayout => SystemUI's H : 34 PanelSwitchLayout(1008400035)#onGlobalLayout => minLimitCloseKeyboardHeight : 72 PanelSwitchLayout(1008400035)#onGlobalLayout => minLimitOpenKeyboardHeight : 300 PanelSwitchLayout(1008400035)#onGlobalLayout => lastKeyboardHeight : 0 PanelSwitchLayout(1008400035)#onGlobalLayout => keyboardH : 0, realKeyboardH : 0, isShown : false D/LogTracker: PanelSwitchLayout(1008400035)#onGlobalLayout =>

面板宽高都是对的,但是就是第一次打开它面板内容就会空白…

YummyLau commented 4 years ago

@TinyCaviar 你这个是否为提供的demo,得看你具体怎么集成的,方便提供下集成代码吗? 另外你可以严格参考demo的实现,也检查下你的面板是否有内容哦。

KennenH commented 4 years ago

@TinyCaviar 你这个是否为提供的demo,得看你具体怎么集成的,方便提供下集成代码吗? 另外你可以严格参考demo的实现,也检查下你的面板是否有内容哦。

demo 是好的,是我集成的问题,但是我基本上就是按照demo集成的,很多代码都是直接copy过来,所以一直想不通 我给我的面板的PanelView加了background,显示空白的时候它面板内容就是没有加载出来,背景颜色也没有

ezgif com-video-to-gif

这是我的一整个ChatActivity.class

public class ChatActivity extends ImmersionStatusBarActivity implements OnRefreshListener {

    public static void start(Context context) {
        Intent intent = new Intent(context, ChatActivity.class);
        context.startActivity(intent);
    }

    public static final int TAKE_PHOTO = 111; // requestCode take photo
    public static final int PICK_PHOTO = 222; // requestCode select from album
    public static final int SELECT_POSITION = 333; // requestCode arrange transaction position

    private PanelSwitchHelper mHelper;

    private ChatViewModel chatViewModel;

    private TextView mUserName;
    private EditText mInput;
    private ImageView mEmoji;
    private ImageView mMore;
    private TextView mSend;

    private RecyclerView mChatRecycler;
    private LinearLayoutManager mChatLayoutManager;
    private RecyclerView mEmojiRecycler;
    private RecyclerView mMoreRecycler;

    private ChatRecyclerAdapter mChatRecyclerAdapter = new ChatRecyclerAdapter();

    private Animation sendOut;
    private Animation moreOut;
    private Animation in;
    private boolean isSendShowing = false;

    private int mUnfilledHeight = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_chat);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        chatViewModel = new ViewModelProvider(this).get(ChatViewModel.class);

        setSupportActionBar(findViewById(R.id.toolbar));
        mUserName = findViewById(R.id.user_name);
        mInput = findViewById(R.id.edit_view);
        mEmoji = findViewById(R.id.chat_bar_emoji);
        mMore = findViewById(R.id.chat_bar_more);
        mSend = findViewById(R.id.chat_bar_send);
        mChatRecycler = findViewById(R.id.recycler_view);
        mEmojiRecycler = findViewById(R.id.emoji_recycler);
        mMoreRecycler = findViewById(R.id.more_recycler);

        mSend.setVisibility(View.GONE);

        initRecyclerLists();
        initEvents();
        initAnim();
    }

    @Override
    protected void onStart() {
        super.onStart();
        if (mHelper == null) {
            mHelper = new PanelSwitchHelper.Builder(this)
                    .addEditTextFocusChangeListener((view, b) -> {
                        if (!b) KeyboardUtils.hideSoftInput(this);
                    })
                    .addContentScrollMeasurer(new ContentScrollMeasurer() {
                        @Override
                        public int getScrollDistance(int defaultDistance) {
                            return defaultDistance - mUnfilledHeight;
                        }

                        @Override
                        public int getScrollViewId() {
                            return R.id.recycler_view;
                        }
                    })
                    .addPanelChangeListener(new OnPanelChangeListener() {
                        @Override
                        public void onPanelSizeChange(@Nullable IPanelView iPanelView, boolean b, int i, int i1, int i2, int i3) {
                        }

                        @Override
                        public void onKeyboard() {
                            mEmoji.setSelected(false);
                            mMore.setSelected(false);
                        }

                        @Override
                        public void onNone() {
                            mEmoji.setSelected(false);
                            mMore.setSelected(false);
                        }

                        @Override
                        public void onPanel(IPanelView view) {
                            mInput.clearFocus();
                            if (view instanceof PanelView) {
                                mEmoji.setSelected(((PanelView) view).getId() == R.id.panel_emotion);
                                mMore.setSelected(((PanelView) view).getId() == R.id.panel_addition);
                            }
                        }
                    })
                    .build();
        }
    }

    @Override
    public void onBackPressed() {
        if (mHelper != null && mHelper.hookSystemBackByPanelSwitcher()) return;
        super.onBackPressed();
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        int id = item.getItemId();
        if (id == android.R.id.home) finish();

        return super.onOptionsItemSelected(item);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = new MenuInflater(this);
        inflater.inflate(R.menu.chat_more, menu);
        menu.getItem(0).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {
        // todo 加载10条历史记录
    }

    ///////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////// 初始化页面 //////////////////////////////////

    /**
     * 初始化动画
     */
    private void initAnim() {
        sendOut = AnimationUtils.loadAnimation(this, R.anim.send_fade_out_right);
        moreOut = AnimationUtils.loadAnimation(this, R.anim.send_fade_out_right);
        in = AnimationUtils.loadAnimation(this, R.anim.send_fade_in_right);
        sendOut.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                mSend.setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mSend.setVisibility(View.GONE);
                mSend.setEnabled(true);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //nothing
            }
        });

        moreOut.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                mMore.setEnabled(false);
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mMore.setVisibility(View.GONE);
                mMore.setEnabled(true);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                //nothing
            }
        });
    }

    /**
     * 初始化监听事件
     */
    private void initEvents() {
        // 输入框输入监听
        mInput.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                String input = mInput.getText().toString();
                if (input.length() != 0) showSend();
                else if (input.equals("")) hideSend();
            }
        });

        // 发送按钮按下监听
        mSend.setOnClickListener(v -> {
            if (mInput.getText().toString().startsWith("...")) {
                mChatRecyclerAdapter.addData(0, new ChatReceiveMessageEntity(mInput.getText().toString().substring(3)));
            } else {
                mChatRecyclerAdapter.addData(0, new ChatSendMessageEntity(mInput.getText().toString()));
            }
            mInput.setText("");
            scrollToFirst();
        });

        // 聊天列表滑动监听
        mChatRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                if (newState == SCROLL_STATE_DRAGGING) { // 消息列表滑动时隐藏键盘和面板
                    if (mHelper.isKeyboardState())
                        mInput.clearFocus();
                    else if (mHelper.isPanelState())
                        mHelper.resetState();
                }
            }

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
                if (layoutManager instanceof LinearLayoutManager) {
                    int childCount = recyclerView.getChildCount();
                    if (childCount > 0) {
                        View newestChildView = recyclerView.getChildAt(0);
                        int bottom = newestChildView.getBottom();
                        int listHeight = mChatRecycler.getHeight() - mChatRecycler.getPaddingBottom();
                        mUnfilledHeight = listHeight - bottom;
                    }
                }
            }
        });
    }

    /**
     * 初始化所有RV
     */
    private void initRecyclerLists() {
        // 聊天列表
        mChatLayoutManager = new LinearLayoutManager(this);
        mChatLayoutManager.setStackFromEnd(true);
        mChatLayoutManager.setReverseLayout(true);
        mChatLayoutManager.setSmoothScrollbarEnabled(true);
        mChatRecycler.setLayoutManager(mChatLayoutManager);
        mChatRecycler.setAdapter(mChatRecyclerAdapter);

        // Emotion,一排七个,均匀分布
        GridLayoutManager emojiManager = new GridLayoutManager(this, 7);
        mEmojiRecycler.addItemDecoration(new GridItemDecoration(7, getResources().getDimension(R.dimen.toolbar_icon)));
        // todo 填充面板内容
        mEmojiRecycler.setLayoutManager(emojiManager);

        // Addition,一排四个,均匀分布
        GridLayoutManager moreManager = new GridLayoutManager(this, 4);
        mMoreRecycler.addItemDecoration(new GridItemDecoration(4, getResources().getDimension(R.dimen.toolbar_center_margin)));
        MorePanelAdapter morePanelAdapter = new MorePanelAdapter();
        morePanelAdapter.setList(PanelMore.getPanelMore());
        mMoreRecycler.setLayoutManager(moreManager);
        mMoreRecycler.setAdapter(morePanelAdapter);
    }

    ////////////////////////////////// 初始化页面 //////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////

    /**
     * 显示发送按钮,隐藏Addition按钮
     */
    private void showSend() {
        if (!isSendShowing) {
            isSendShowing = true;
            mSend.setVisibility(View.VISIBLE);
            mMore.startAnimation(moreOut);
            mSend.startAnimation(in);
        }
    }

    /**
     * 显示Addition按钮,隐藏发送按钮
     */
    private void hideSend() {
        if (isSendShowing) {
            isSendShowing = false;
            mMore.setVisibility(View.VISIBLE);
            mMore.startAnimation(in);
            mSend.startAnimation(sendOut);
        }
    }

    /**
     * 将列表滑动至最底下
     */
    private void scrollToFirst() {
        mChatLayoutManager.scrollToPosition(0);
    }
}

这是我的activity_chat.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:viewBindingIgnore="true">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:elevation="0dp"
        app:contentInsetEnd="@dimen/toolbar_center_margin"
        app:layout_constraintTop_toTopOf="parent"
        app:menu="@menu/chat_more"
        app:navigationIcon="@drawable/ic_left">

        <TextView
            android:id="@+id/user_name"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:ellipsize="end"
            android:gravity="center"
            android:textColor="@color/black"
            tools:text="小鱼子酱" />
    </androidx.appcompat.widget.Toolbar>

    <com.effective.android.panel.view.PanelSwitchLayout
        android:id="@+id/panel_switch_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:background="@color/white"
        android:orientation="vertical"
        app:animationSpeed="standard"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar">

        <!-- linear_edit_view 指定一个 EditText 用于输入 ,必须项-->
        <!-- linear_auto_reset_enable 指定是否 LinearContentContainer 是否能够接受 Touch 事件自动隐藏面板-->
        <!-- linear_auto_reset_area 指定是否 LinearContentContainer 只接受某个 View 区域的 Touch 事件来自定隐藏面板-->
        <com.example.schoolairdroprefactoredition.ui.components.CusContentContainer
            android:id="@+id/content_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            app:hide_by_touch_area="@id/recycler_view"
            app:hide_by_touch_outside_enable="true"
            app:input_view="@id/edit_view">

            <com.example.schoolairdroprefactoredition.ui.auto.OverDragLayout
                android:id="@+id/recycler_container"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_above="@+id/bottom_action"
                app:layout_constraintBottom_toTopOf="@+id/bottom_action"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/recycler_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="0dp"
                    android:overScrollMode="never"
                    android:tag="recycler_view" />
            </com.example.schoolairdroprefactoredition.ui.auto.OverDragLayout>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/bottom_action"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                app:layout_constraintBottom_toBottomOf="parent">

                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/guideline0"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    app:layout_constraintGuide_end="43dp" />

                <androidx.constraintlayout.widget.Guideline
                    android:id="@+id/guideline1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    app:layout_constraintGuide_end="@dimen/general_padding" />

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/input_container"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:focusable="true"
                    android:focusableInTouchMode="true"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@id/send_and_more"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        app:layout_constraintGuide_end="43dp" />

                    <androidx.constraintlayout.widget.Guideline
                        android:id="@+id/guideline3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        app:layout_constraintGuide_end="@dimen/general_padding" />

                    <EditText
                        android:id="@+id/edit_view"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/general_padding"
                        android:background="@drawable/bg_rounded_primary5"
                        android:imeOptions="actionSearch"
                        android:inputType="textMultiLine|textShortMessage"
                        android:letterSpacing="0.1"
                        android:lineSpacingExtra="1dp"
                        android:maxLines="4"
                        android:minHeight="@dimen/toolbar_icon_large"
                        android:paddingStart="@dimen/general_padding_large"
                        android:paddingTop="@dimen/general_padding"
                        android:paddingEnd="@dimen/general_padding_large"
                        android:paddingBottom="@dimen/general_padding"
                        android:textColor="?attr/colorControlNormal"
                        android:textCursorDrawable="@drawable/cursor"
                        android:textSize="@dimen/textSizeNormal"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toStartOf="@id/chat_bar_emotion"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <ImageView
                        android:id="@+id/chat_bar_emotion"
                        android:layout_width="@dimen/toolbar_icon_bit_large"
                        android:layout_height="@dimen/toolbar_icon_bit_large"
                        android:layout_marginEnd="@dimen/general_padding"
                        android:src="@drawable/ic_face"
                        app:layout_constraintBottom_toTopOf="@id/guideline3"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toBottomOf="@id/guideline2" />
                </androidx.constraintlayout.widget.ConstraintLayout>

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/send_and_more"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginEnd="@dimen/general_padding"
                    app:layout_constraintBottom_toTopOf="@+id/guideline1"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/guideline0">

                    <TextView
                        android:id="@+id/chat_bar_send"
                        android:layout_width="60dp"
                        android:layout_height="@dimen/toolbar_icon_large"
                        android:background="@drawable/bg_rounded_theme"
                        android:gravity="center"
                        android:text="@string/send"
                        android:textColor="#ffffff"
                        android:textSize="17dp"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />

                    <ImageView
                        android:id="@+id/chat_bar_addition"
                        android:layout_width="@dimen/toolbar_icon_bit_large"
                        android:layout_height="@dimen/toolbar_icon_bit_large"
                        android:src="@drawable/ic_chat_more"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.constraintlayout.widget.ConstraintLayout>
        </com.example.schoolairdroprefactoredition.ui.components.CusContentContainer>

        <!-- 面板区域,仅能包含PanelView-->
        <com.effective.android.panel.view.panel.PanelContainer
            android:id="@+id/panel_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white">

            <!-- panel_layout 用于指定面板该 ID 对应的布局 ,必须项-->
            <!-- panel_trigger 用于用户点击该 ID 对应的 View 时切换到该面板 -->
            <!-- panel_toggle  用于当该面板显示时 ,用户再次点击 panel_trigger 对应的 View 时是否回切输入法-->
            <com.effective.android.panel.view.panel.PanelView
                android:id="@+id/panel_emotion"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                **android:background="@color/black"**
                app:panel_layout="@layout/component_panel_emotion"
                app:panel_toggle="true"
                app:panel_trigger="@id/chat_bar_emotion" />

            <com.effective.android.panel.view.panel.PanelView
                android:id="@+id/panel_addition"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                **android:background="@color/red"**
                app:panel_layout="@layout/component_panel_addition"
                app:panel_toggle="true"
                app:panel_trigger="@id/chat_bar_addition" />
        </com.effective.android.panel.view.panel.PanelContainer>
    </com.effective.android.panel.view.PanelSwitchLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

这两个是我的面板内容布局 component_panel_addition.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/edditioin_recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never" />

component_panel_emotion.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/emotion_recycler"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:overScrollMode="never" />
YummyLau commented 4 years ago

@TinyCaviar 你加一下我微信,帮你看一下,应该是集成的问题。

YummyLau commented 4 years ago

@TinyCaviar post延迟下你第一次打开的时机。

KennenH commented 4 years ago

@TinyCaviar 你加一下我微信,帮你看一下,应该是集成的问题。

我今天跑在redmi k30 android10上,发现是好的,晚上我多测试几个机型看看…

zhujunhua2012 commented 2 years ago

我用android模拟器 5.0跑集成后的项目,也有这个问题(只是面板没显示,有点像invisible,但是可以点击面板上的控件,有事件响应); 但是跑的demo没有问题。。。

zhujunhua2012 commented 2 years ago

我用android模拟器 5.0跑集成后的项目,也有这个问题(只是面板没显示,有点像invisible,但是可以点击面板上的控件,有事件响应); 但是跑的demo没有问题。。。

按钮触发panel展开的事件, PanelSwitchLayout#checkoutPanel中设置panel visible之后调用的requestLayout,放在post里面就可以了。(监听panle的事件,PanelSwitchHelper.Builder#addPanelChangeListener#onPanel里面post执行#requestLayout,就是有点重复了) 不知道为啥要放在post里,好像好多ui的问题,都是post延迟可以解决的。。。