LayoutParams
LayoutParams是什么
中文翻译过来就是“布局参数”。
LayoutParams是Layout提供给其中的Children使用的,他其实就是告诉布局(Parent),控件(Children)想要多宽,想要多高,看一下官方文档。
1.LayoutParams are used by views to tell their parents how they want to be laid out.
– LayoutParams是View用来告诉它的父控件如何放置自己的。2.The base LayoutParams class just describes how big the view wants to be for both width and height.
– 基类LayoutParams(也就是ViewGroup.LayoutParams)仅仅描述了这个View想要的宽度和高度。3.There are subclasses of LayoutParams for different subclasses of ViewGroup.
– 不同ViewGroup的继承类对应着不同的ViewGroup.LayoutParams的子类。
文档第二点:基类LayoutParams也就是(ViewGroup.LayoutParams)所能使用的参数只有两种
//第一种
ViewGroup.LayoutParams.MATCH_PARENT
//第二种
ViewGroup.LayoutParams.WRAP_CONTENT
文档第三点:这里用2张继承图解释一下。
简单使用
举例TextView
LinearLayout parent = (LinearLayout)findViewById(R.id.ly_parent);
TextView textView = new TextView(this);
textView.setText("举例");
textView.setTextColor(Color.BLUE);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 50);
parent.addView(textView,lp);
https://blog.csdn.net/yisizhu/article/details/51582622#t1
LayoutParams相关推荐
- Android 中文 API 文档 (45) —— AbsoluteLayout.LayoutParams
前言 本章内容是 android.widget.AbsoluteLayout.LayoutParams,版本为Android 2.2 r1,翻译来自"绵白糖",再次感谢" ...
- WindowManager.LayoutParams各种flag含义
本文实际上就是翻译了官方文档的flag部分,以便使用的时候对照. flags变量设置的值的各种意义//---------------1--------------------------------- ...
- WindowManager.LayoutParams类22
引用:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=84893 WindowManager.LayoutParams 是 Win ...
- Android中setLayoutParams要用父控件的LayoutParams
这几天做程序想明白了一个问题,在此做一下记录. ActionBarCustomView customview = new ActionBarCustomView(context); ActionBar ...
- new LayoutParams 使用
ImageView imageView = new ImageView(mcontext); LayoutParams layoutParams = new LayoutParams(150,130) ...
- java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
最近,在android中用代码动态改变某种布局(组件)的高度时,会遇到如题所示的类转换异常.上网查了一下,如下所示: These supply parameters to the parent of ...
- 【Android】动态UI : LayoutParams.addRule(...) LayoutParams.addRule(..., ...)
LayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); LayoutParams.addRule(RelativeLayout.ABOVE, ...
- ViewGroup.LayoutParams
LayoutParams are used by views to tell their parents how they want to be laid out. (LayoutPrarms 用于表 ...
- 关于LayoutParams
每一个布局均有一个叫LayoutParams的内部类,如: LinearLayout.LayoutParams RelativeLayout.LayoutParams AbsoluteLayout ...
- AbsListView.LayoutParams
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(-1, -2); 创建一个布局(LayoutParams)的实例 lp. AbsL ...
最新文章
- NCBI中SRA数据库简介
- python标准库学习9
- Linux知识点记录
- redis的安全性及客户端工具的使用
- C/C++ ultoa函数 - C语言零基础入门教程
- 2013.3.9学习日记
- 【Python-2.7】删除空格
- [leetcode]831. 隐藏个人信息
- [PHP 作为iOS后台Json格式HTTP通信及文件上传的实现]
- linux系统移植篇(一)—— linux系统组成
- Oracle性能优化(11g)
- windows强制删除文件
- asp.net实现一个简易购物车功能。
- JavaScript实现涂鸦笔
- 大型施工程机械设备资产管理融资租赁方案
- 虚拟机安装安装增强失败:modprobe vboxguest failed
- 【单片机毕业设计】【mcuclub-jj-013】基于单片机的衣柜的设计
- web 开发入门(1)
- CGB2103-day16-17
- Java汉字转拼音(全拼、首字母拼)
热门文章
- latex常用语法笔记
- 【STM32】SysTick
- 技术交流:一语道破Springboot使用@Valid失效的原因
- JS 的新一代日期/时间 API Temporal和 Moment.js的继承者
- 新手入门Chrome插件(扩展)开发全攻略
- YOLOv4阅读笔记(附思维导图)!YOLOv4: Optimal Speed and Accuracy of Object Detection
- slambook2(ch11)—— Ubuntu18.04安装DBoW3 + 例程演示
- 在word中如何取消分隔符(转)
- log4j2的JsonLayout测试
- Kerberos原理--经典对话