Giter Club home page Giter Club logo

Comments (5)

HeroZ-Dodge avatar HeroZ-Dodge commented on August 24, 2024

你好,请问你遇到这个问题的设备信息是什么。
另外你提到获取虚拟返回键的高度,具体是指哪部分源码

from panelswitchhelper.

chenciyaun avatar chenciyaun commented on August 24, 2024

设备名称:华为P9,型号VIE-AL10 EMUI版本8.0.0 安卓版本8.0.0 有虚拟返回键盘

采用头条的适配方案在聊天界面设置
@OverRide
public Resources getResources() {
return AdaptScreenUtils.adaptWidth(super.getResources(), 360);
}

就会出现底部的虚拟返回键会挡住部分输入框的布局。

经过定位分析发现是工具类DisplayUtil 131行 getNavigationBarHeight 获取的高度减少了一半,带有虚拟返回键的手机才会出现这个问题。

解决方案:修改DisplayUtil 154行的 getInternalDimensionSize这个方法
private fun getInternalDimensionSize(key: String): Int {
val res = Resources.getSystem()// 关键修改点
var result = 0
val resourceId = res.getIdentifier(key, Constants.DIMEN, Constants.ANDROID)
if (resourceId > 0) {
result = res.getDimensionPixelSize(resourceId)
}
return result
}

审查合理的话,希望可以更新下。我现在的修改是直接下载源码进行修改的。

from panelswitchhelper.

HeroZ-Dodge avatar HeroZ-Dodge commented on August 24, 2024

getInternalDimensionSize 用于获取当前页面导航栏的高度,通过Resources.getSystem() 获取的高度和实际高度会有差异,会导致测量高度不准确

from panelswitchhelper.

skyCracks avatar skyCracks commented on August 24, 2024

建议这样修改兼容性会更强一些:
fun getInternalDimensionSize(context: Context, key: String): Int {
val result = 0
try {
val resourceId = Resources.getSystem().getIdentifier(key, Constants.DIMEN, Constants.ANDROID)
if (resourceId > 0) {
val sizeOne = context.resources.getDimensionPixelSize(resourceId)
val sizeTwo = Resources.getSystem().getDimensionPixelSize(resourceId)
return if (sizeTwo >= sizeOne && !(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
key != Constants.STATUS_BAR_HEIGHT_RES_NAME)
) {
sizeTwo
} else {
val densityOne = context.resources.displayMetrics.density
val densityTwo = Resources.getSystem().displayMetrics.density
val f = sizeOne * densityTwo / densityOne
(if (f >= 0) f + 0.5f else f - 0.5f).toInt()
}
}
} catch (ignored: NotFoundException) {
return 0
}
return result
}

from panelswitchhelper.

15359947959 avatar 15359947959 commented on August 24, 2024

from panelswitchhelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.