WindowManager wm = (WindowManager) getContext()
.getSystemService(Context.WINDOW_SERVICE);
int width = wm.getDefaultDisplay().getWidth();
int height = (int) (width - 22*density) / 3;
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) mLinearLayoutTrafficControl.getLayoutParams();
lp.height = height;
LinearLayout.LayoutParams lp2 = (LinearLayout.LayoutParams) mLinearLayoutTrafficControl2.getLayoutParams();
lp2.height = height;
LinearLayout.LayoutParams lp3 = (LinearLayout.LayoutParams) mLinearLayoutTrafficServicesBusinessOnline.getLayoutParams();
lp3.height = height;

注解:先获取屏幕宽度,通过屏幕宽度获取布局的高度。

density:是默认密度 private float density = 1.5f;

动态添加LinearLayout的高度的更多相关文章

  1. android动态添加TextView或者ImageView

    动态添加 text1=new TextView(this); text1.setText("动态添加"); ((LinearLayout) this.findViewById(R. ...

  2. 动态添加布局、动态添加View、LinearLayout动态添加View;

    LinearLayout提供了几个方法,用作动态添加View特别好用: 可以添加View.删除View.删除指定位置View.删除全部View: 看代码: public class MainActiv ...

  3. Mono for android 如何动态添加View,线程内部如何更新UI.

    貌似所有设计到UI的程序原理都是一样的,子线程是不能够更新UI状态的,所以就必须使用UI自身或者第三方来更新UI. 如 在WinForm 中 就可以使用Control.Invoke(Action ac ...

  4. 动态添加PopupWindow

    动态添加PopupWindow的方法private void showPopupWindow() { LayoutInflater inflater = LayoutInflater.from(thi ...

  5. Android 在布局容器中动态添加控件

    这里,通过一个小demo,就可以掌握在布局容器中动态添加控件,以动态添加Button控件为例,添加其他控件同样道理. 1.addView 添加控件到布局容器 2.removeView 在布局容器中删掉 ...

  6. 实现ScrollView中包含ListView,动态设置ListView的高度

    ScrollView 中包含 ListView 的问题 : ScrollView和ListView会冲突,会导致ListView显示不全 <?xml version="1.0" ...

  7. 使用Fragment 实现动态UI 和 动态添加Fragment

    首先写好每个Fragment: 1.在第一个Fragment写一个按钮,使其加载下一个Fragment 布局: <LinearLayout xmlns:android="http:// ...

  8. Android 在程序中动态添加 View 布局或控件

    有时我们需要在程序中动态添加布局或控件等,下面用程序来展示一下相应的方法: 1.addView 添加View到布局容器 2.removeView 在布局容器中删掉已有的View 3.LayoutPar ...

  9. 小生功能贴<一> --- 动态添加应用 具有长按删除功能

    ---恢复内容开始--- 动态添加应用 具有长按删除功能 功能如下图:                (图片显示功能不是你要的,那就默默关闭页面吧) 设计思路: 页面一:用girdview网格显示图标 ...

随机推荐

  1. '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error

    '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error 异常现象 ### Cause: java.sql.SQ ...

  2. <<< php程序在运行后报“internal server error”错误

    上传的php程序在运行后报“internal server error”错误,检查以下两方面: 1.请您检查php程序的属性是否设置为755,如果php程序的属性不是755,那么运行的时候会报“int ...

  3. lua 例子

    //顶 - - - //顶 #include <stdio.h> #include <string.h> extern "C"{ #include < ...

  4. 11月7日下午PHP----PDO访问方式操作数据库

    MySQLI是专门访问MySQL数据库的,不能访问其它数据库.PDO可以访问多种的数据库,它把操作类合并在一起,做成一个数据访问抽象层,这个抽象层就是PDO,根据类操作对应的数据库.mysqli是一个 ...

  5. Finalize()、Dispose()、SafeHandle、GC

    Finalize https://msdn.microsoft.com/en-us/library/system.object.finalize%28v=vs.110%29.aspx https:// ...

  6. Python之路【第二十篇】其他WEB框架

    WEB框架功能分析 WEB框架本质上,就是一个SOCKET Server WEB框架前面有WSGI或者是自己写的SOCKET,然后交给URL路由系统处理,然后交给某个函数或某个类,然后在模板里拿到模板 ...

  7. 【转】 解读EOF

    解读EOF 标签: fplinuxc语言filestream 2012-01-31 22:05 439人阅读 评论(0) 收藏 举报  分类: C.C++_程序设计(20)  我学习C语言的时候,遇到 ...

  8. Response.End()出现ThreadAbortException 异常

    A. 如果使用 Response.End.Response.Redirect 或 Server.Transfer 方法,将出现 ThreadAbortException 异常.异常内容:由于代码已经过 ...

  9. Websites for more Android development information

    There is a vibrant, helpful Android developer community on the Web. Here are a numberof useful websi ...

  10. Lua手动编译姿势

    LUA-5.3.3.tar.gz Lua源码+链接2016年5月30日更新 手动编译姿势: 已经装有VS2010 使用VS自带的 cl.exe以及 VS命令簿 打开文件地址 运行自己的bat文件 my ...