-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
android 7.0适配 #31
Comments
同问,Android 7.0 遇到 layout_marginLeftPercent 属性失效问题,低于 7.0 正常。 |
7.0适配的话,修改下源码PercentLayoutHelperl类的方法fillMarginLayoutParams就可以了
|
谢谢。
…________________________________
发件人: yeyueduxing <[email protected]>
发送时间: 2017年8月15日 0:02:05
收件人: hongyangAndroid/android-percent-support-extend
抄送: 王英豪; Comment
主题: Re: [hongyangAndroid/android-percent-support-extend] android 7.0适配 (#31)
7.0适配的话,修改下源码PercentLayoutHelperl类的方法fillMarginLayoutParams就可以了
public void fillMarginLayoutParams(ViewGroup.MarginLayoutParams params, int widthHint,
int heightHint)
{
fillLayoutParams(params, widthHint, heightHint);
// Preserver the original margins, so we can restore them after the measure step.
mPreservedParams.leftMargin = params.leftMargin;
mPreservedParams.topMargin = params.topMargin;
mPreservedParams.rightMargin = params.rightMargin;
mPreservedParams.bottomMargin = params.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(mPreservedParams,
MarginLayoutParamsCompat.getMarginStart(params));
MarginLayoutParamsCompat.setMarginEnd(mPreservedParams,
MarginLayoutParamsCompat.getMarginEnd(params));
if (leftMarginPercent != null)
{
int base = getBaseByModeAndVal(widthHint, heightHint, leftMarginPercent.basemode);
params.leftMargin = (int) (base * leftMarginPercent.percent);
}
if (topMarginPercent != null)
{
int base = getBaseByModeAndVal(widthHint, heightHint, topMarginPercent.basemode);
params.topMargin = (int) (base * topMarginPercent.percent);
}
if (rightMarginPercent != null)
{
int base = getBaseByModeAndVal(widthHint, heightHint, rightMarginPercent.basemode);
params.rightMargin = (int) (base * rightMarginPercent.percent);
}
if (bottomMarginPercent != null)
{
int base = getBaseByModeAndVal(widthHint, heightHint, bottomMarginPercent.basemode);
params.bottomMargin = (int) (base * bottomMarginPercent.percent);
}
if (startMarginPercent != null)
{
int base = getBaseByModeAndVal(widthHint, heightHint, startMarginPercent.basemode);
MarginLayoutParamsCompat.setMarginStart(params,
(int) (base * startMarginPercent.percent));
}
if (endMarginPercent != null)
{
int base = getBaseByModeAndVal(widthHint, heightHint, endMarginPercent.basemode);
MarginLayoutParamsCompat.setMarginEnd(params,
(int) (base * endMarginPercent.percent));
}
if (Log.isLoggable(TAG, Log.DEBUG))
{
//Log.d(TAG, "after fillMarginLayoutParams: (" + params.width + ", " + params.height
// + ")");
}
//7.0系统修改下mPreservedParams数据
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.N){
mPreservedParams.leftMargin = params.leftMargin;
mPreservedParams.topMargin = params.topMargin;
mPreservedParams.rightMargin = params.rightMargin;
mPreservedParams.bottomMargin = params.bottomMargin;
MarginLayoutParamsCompat.setMarginStart(mPreservedParams,
MarginLayoutParamsCompat.getMarginStart(params));
MarginLayoutParamsCompat.setMarginEnd(mPreservedParams,
MarginLayoutParamsCompat.getMarginEnd(params));
}
}
―
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#31 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AWHERvELOsFoDIiQ7x7WnILPhemZ7frhks5sYUJsgaJpZM4L4_VD>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最近测试机更新了7.0 之前合适的布局除了问题。请问是不兼容7.0嘛?
The text was updated successfully, but these errors were encountered: