之前账号的文章2:Context-menu.Android库的使用(修改显示位置)
来源:互联网 发布:迈越网络刀塔传奇 编辑:程序博客网 时间:2024/05/29 10:38
这个库iOS版可以直接调用一个改变位置的方法即可,但Android需要修改相关源码,我是修改为右下显示,解决方法:
1.修改fragment_menu:
<LinearLayout android:id="@+id/wrapper_buttons" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true"/><LinearLayout android:id="@+id/wrapper_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_toLeftOf="@+id/wrapper_buttons" android:layout_toStartOf="@+id/wrapper_buttons" android:layout_alignParentBottom="true" android:layout_marginRight="@dimen/text_wrapper_right_margin" android:layout_marginEnd="@dimen/text_wrapper_right_margin" android:gravity="end" />2.修改menuAdapter,我这里只用修改3个位置:
1.
private void resetAnimations() { for (int i = 0; i < getItemCount(); i++) { resetTextAnimation(mTextWrapper.getChildAt(i)); if (i == getItemCount()-1) { resetSideAnimation(mMenuWrapper.getChildAt(i)); } else { resetVerticalAnimation(mMenuWrapper.getChildAt(i), true); } }}
2.private AnimatorSet setOpenCloseAnimation(boolean isCloseAnimation) { List<Animator> textAnimations = new ArrayList<>(); List<Animator> imageAnimations = new ArrayList<>(); //true就是隐藏,从大到小隐藏。 if (isCloseAnimation) { for (int i = getItemCount() - 1; i >= 0; i--) { fillOpenClosingAnimations(true, textAnimations, imageAnimations, i); } } else { //显示从后往前显示 for (int i = getItemCount() - 1; i >= 0; i--) { fillOpenClosingAnimations(false, textAnimations, imageAnimations, i); } }3.private void fillOpenClosingAnimations(boolean isCloseAnimation, List<Animator> textAnimations, List<Animator> imageAnimations, int wrapperPosition) { AnimatorSet textAnimatorSet = new AnimatorSet(); Animator textAppearance = isCloseAnimation ? AnimatorUtils.alfaDisappear(mTextWrapper.getChildAt(wrapperPosition)) : AnimatorUtils.alfaAppear(mTextWrapper.getChildAt(wrapperPosition)); Animator textTranslation = isCloseAnimation ? AnimatorUtils.translationRight(mTextWrapper.getChildAt(wrapperPosition), mContext.getResources().getDimension(R.dimen.text_right_translation)) : AnimatorUtils.translationLeft(mTextWrapper.getChildAt(wrapperPosition), mContext.getResources().getDimension(R.dimen.text_right_translation)); textAnimatorSet.playTogether(textAppearance, textTranslation); textAnimations.add(textAnimatorSet); Animator imageRotation = isCloseAnimation ? wrapperPosition == 0 ? AnimatorUtils.rotationCloseToRight(mMenuWrapper.getChildAt(wrapperPosition)) : AnimatorUtils.rotationCloseVertical(mMenuWrapper.getChildAt(wrapperPosition)) : wrapperPosition == getItemCount()-1 ? AnimatorUtils.rotationOpenFromRight(mMenuWrapper.getChildAt(wrapperPosition)) : AnimatorUtils.rotationOpenVertical(mMenuWrapper.getChildAt(wrapperPosition)); imageAnimations.add(imageRotation);}完工。。。。。
0 0
- 之前账号的文章2:Context-menu.Android库的使用(修改显示位置)
- Context-Menu.Android库的使用(修改显示位置)
- 之前账号的文章1:android各种格式文件的打开
- Option Menu && Context Menu的使用
- android的Context Menu菜单
- Android的context menu组件
- 解决IE浏览器使用UEditor修改文章后,重新打开文章,显示修改之前内容的问题
- Android应用中菜单(Menu)的位置显示问题
- Android应用中菜单(Menu)的位置显示问题
- Android中Option menu和Context menu的使用(十六)
- Android中修改toast的显示位置
- 修改 android Dialog 对话框显示的位置
- Android 的上下文菜单: Context Menu
- Android 的上下文菜单: Context Menu
- Android 的上下文菜单: Context Menu
- Android 的上下文菜单: Context Menu
- Android 的上下文菜单: Context Menu
- Android 的上下文菜单: Context Menu
- 控制台
- iOS 实现下一题功能
- 使用MediaRecorder进行录音的步骤(初稿)
- android 用键盘操作 gridview焦点移动到屏幕外 页面不跟着滚动
- 《C#精彩实例教程》小组阅读08 -- C#流程控制语句
- 之前账号的文章2:Context-menu.Android库的使用(修改显示位置)
- CSS3初步
- Activity跳转时,监听Service无法进行监听响应
- js,jsp中解决get乱码
- servlet_15 数据库访问
- Android音视频学习第0章:音视频处理基础
- nginx反向代理和负载均衡
- 欢迎使用CSDN-markdown编辑器
- 1.7本章主要内容