gpt4 book ai didi

Android Studio 无法解析方法 addRule()

转载 作者:行者123 更新时间:2023-11-29 15:18:05 24 4
gpt4 key购买 nike

ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

我得到:错误:找不到符号方法 addRule(int)

Android Studio 0.4.5 版

最佳答案

因为你使用了ViewGroup.LayoutParams

ViewGroup.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

但是 addRule 方法是在子类 RelativeLayout.LayoutParams 中实现的,所以你可能想改用:

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(containerWidth, fragmentHeight);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

参见 documentation of RelativeLayout.LayoutParams here

关于Android Studio 无法解析方法 addRule(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22129399/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com