Java Code Examples for de.hdodenhof.circleimageview.CircleImageView#getWidth()
The following examples show how to use
de.hdodenhof.circleimageview.CircleImageView#getWidth() .
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: AvatarImageBehavior.java From Android-skin-support with MIT License | 5 votes |
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, CircleImageView child, View dependency) { // 初始化属性 shouldInitProperties(child, dependency); // 最大滑动距离: 起始位置-状态栏高度 final int maxScrollDistance = (int) (mStartToolbarPosition - getStatusBarHeight()); // 滑动的百分比 float expandedPercentageFactor = dependency.getY() / maxScrollDistance; // Y轴距离 float distanceYToSubtract = ((mStartYPosition - mFinalYPosition) * (1f - expandedPercentageFactor)) + (child.getHeight() / 2); // X轴距离 float distanceXToSubtract = ((mStartXPosition - mFinalXPosition) * (1f - expandedPercentageFactor)) + (child.getWidth() / 2); // 高度减小 float heightToSubtract = ((mStartHeight - mFinalHeight) * (1f - expandedPercentageFactor)); // 图片位置 child.setY(mStartYPosition - distanceYToSubtract); child.setX(mStartXPosition - distanceXToSubtract); // 图片大小 CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); lp.width = (int) (mStartHeight - heightToSubtract); lp.height = (int) (mStartHeight - heightToSubtract); child.setLayoutParams(lp); return true; }
Example 2
Source File: AvatarImageBehavior.java From Android-skin-support with MIT License | 5 votes |
/** * 初始化动画值 * * @param child 图片控件 * @param dependency ToolBar */ private void shouldInitProperties(CircleImageView child, View dependency) { // 图片控件中心 if (mStartYPosition == 0) mStartYPosition = (int) (child.getY() + (child.getHeight() / 2)); // Toolbar中心 if (mFinalYPosition == 0) mFinalYPosition = (dependency.getHeight() / 2); // 图片高度 if (mStartHeight == 0) mStartHeight = child.getHeight(); // Toolbar缩略图高度 if (mFinalHeight == 0) mFinalHeight = mContext.getResources().getDimensionPixelOffset(R.dimen.image_final_width); // 图片控件水平中心 if (mStartXPosition == 0) mStartXPosition = (int) (child.getX() + (child.getWidth() / 2)); // 边缘+缩略图宽度的一半 if (mFinalXPosition == 0) mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + (mFinalHeight / 2); // Toolbar的起始位置 if (mStartToolbarPosition == 0) mStartToolbarPosition = dependency.getY() + (dependency.getHeight() / 2); }
Example 3
Source File: AvatarImageBehavior.java From Android-skin-support with MIT License | 5 votes |
@Override public boolean onDependentViewChanged(CoordinatorLayout parent, CircleImageView child, View dependency) { // 初始化属性 shouldInitProperties(child, dependency); // 最大滑动距离: 起始位置-状态栏高度 final int maxScrollDistance = (int) (mStartToolbarPosition - getStatusBarHeight()); // 滑动的百分比 float expandedPercentageFactor = dependency.getY() / maxScrollDistance; // Y轴距离 float distanceYToSubtract = ((mStartYPosition - mFinalYPosition) * (1f - expandedPercentageFactor)) + (child.getHeight() / 2); // X轴距离 float distanceXToSubtract = ((mStartXPosition - mFinalXPosition) * (1f - expandedPercentageFactor)) + (child.getWidth() / 2); // 高度减小 float heightToSubtract = ((mStartHeight - mFinalHeight) * (1f - expandedPercentageFactor)); // 图片位置 child.setY(mStartYPosition - distanceYToSubtract); child.setX(mStartXPosition - distanceXToSubtract); // 图片大小 CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); lp.width = (int) (mStartHeight - heightToSubtract); lp.height = (int) (mStartHeight - heightToSubtract); child.setLayoutParams(lp); return true; }
Example 4
Source File: AvatarImageBehavior.java From Android-skin-support with MIT License | 5 votes |
/** * 初始化动画值 * * @param child 图片控件 * @param dependency ToolBar */ private void shouldInitProperties(CircleImageView child, View dependency) { // 图片控件中心 if (mStartYPosition == 0) mStartYPosition = (int) (child.getY() + (child.getHeight() / 2)); // Toolbar中心 if (mFinalYPosition == 0) mFinalYPosition = (dependency.getHeight() / 2); // 图片高度 if (mStartHeight == 0) mStartHeight = child.getHeight(); // Toolbar缩略图高度 if (mFinalHeight == 0) mFinalHeight = mContext.getResources().getDimensionPixelOffset(R.dimen.image_final_width); // 图片控件水平中心 if (mStartXPosition == 0) mStartXPosition = (int) (child.getX() + (child.getWidth() / 2)); // 边缘+缩略图宽度的一半 if (mFinalXPosition == 0) mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + (mFinalHeight / 2); // Toolbar的起始位置 if (mStartToolbarPosition == 0) mStartToolbarPosition = dependency.getY() + (dependency.getHeight() / 2); }