Open
Conversation
首先编码改成了u8,然后将pickview的一些属性暴露出来,例如最大最小文字,颜色,透明度等暴露成attrs中的属性值来让用户自定义,接着解决了width和height设置为Warp_content的时候pickerview全屏问题,设置了默认值,同时兼容fill_parent和自己设置大小。改动不算太大,更加自由了一些。
|
@SeaSoon 的Pull Requests的init()方法中获取XML里设置的width和height不太靠谱,只针对了dp、dip,无法应对px。可以考虑以下方式: ViewGroup.LayoutParams layoutParams = getLayoutParams();
if (layoutParams == null) {
layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
int width = layoutParams.width;
int height = layoutParams.height;
final float scale = context.getResources().getDisplayMetrics().density;
if (width == ViewGroup.LayoutParams.WRAP_CONTENT) {
if (mMaxTextSize == 0) {
mViewHeight = (int) (160 * scale + 0.5f);
mViewWidth = (int) (80 * scale + 0.5f);
} else {
mViewHeight = (int) mMaxTextSize * 4;
mViewWidth = (int) mMaxTextSize * 2;
}
useDefault = true;
} else if (width == ViewGroup.LayoutParams.MATCH_PARENT) {
useDefault = false;
} else {
mViewHeight = (int) (height * scale + 0.5f);
mViewWidth = (int) (width * scale + 0.5f);
useDefault = true;
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
首先编码改成了u8,然后将pickview的一些属性暴露出来,例如最大最小文字,颜色,透明度等暴露成attrs中的属性值来让用户自定义,接着解决了width和height设置为Warp_content的时候pickerview全屏问题,设置了默认值,同时兼容fill_parent和自己设置大小。改动不算太大,更加自由了一些。