android - 用LayoutParams动态设置高度,在不同手机上显示效果不一样
黄舟
黄舟 2017-04-17 17:39:34
0
1
795

比如LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,440);我这样设置后在我的手机上显示的是完整的,在别的手机上显示不完整。
我也使用了网上搜到的方法:int screenHeight=getWindowManager().getDefaultDisplay().getHeight();
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,(int)(0.3*screenHeight));这个又没法算准百分比,真纳闷

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
洪涛

Please use the tool class to convert dpi to px first and then set it up

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!