android动态设置maxWidth,如何使用android:maxWidth?
I want to set a maximum width of an edit box.
在你的例子中:
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10" />
layout_width和ems属性正在尝试设置相同的值。 Android似乎选择较大的fill_parent值并忽略另一个。当你使用这个:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:maxWidth="50dp"
android:minWidth="50dp" />
这里ems和maxWidth正在尝试设置相同的值,再次使用更大的值。所以取决于你实际想要什么,你可以使用:
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" />
或者如果您喜欢使用dp,请将android:ems =“10”替换为android:maxWidth =“50dp”。
最后你的LinearLayout只有一个孩子,EditText。通常情况下,您可以删除LinearLayout标签,并自行使用EditText。
android动态设置maxWidth,如何使用android:maxWidth?相关推荐
- android 动态设置style属性值,android中的style属性值,以及一些预定义样式
Android平台定义的主题样式:android:theme="@android:style/Theme.Dialog" // 将一个Activity显示为对话框模式 androi ...
- android动态设置冷启动图片拉伸变形,Android冷启动时间优化
冷启动时间是指当用户点击你的app那一刻到系统调用Activity.onCreate()之间的时间段.在这个时间段内,WindowManager会先加载app主题样式中的windowBackgroun ...
- android 动态设置padding,Android动态设置控件大小以及设定margin以及padding值
http://www.aichengxu.com/Java/73893.htm Android动态设置控件大小以及设定margin以及padding值,有需要的朋友可以参考下. 一.概述 在andro ...
- android 动态改变语言,android动态设置app当前运行语言的方法
android开发中有时候碰到切换语言的需求,这时候需要通过代码动态改变当前运行语言. package com.example.androidtest; import java.util.Locale ...
- Android 动态设置宽高
Android 动态设置宽高 val params: FrameLayout.LayoutParams = view?.layoutParams as FrameLayout.LayoutParams ...
- android 动态设边距,在代码中动态设置页边距 - android
我有一个只包含ScrollView和TableLayout的活动.在我的代码我加入tablerows,一切工作正常,除了利润 - 它不工作(没有任何反应),下面是代码:在代码中动态设置页边距 - an ...
- android textview layoutparams,Android动态设置布局的LayoutParams属性总遇到造型异常
Android动态设置布局的setLayoutParams()属性总遇到造型异常问题 android:id="@+id/introduce" android:layout_widt ...
- android 如何动态设置margin,Android 动态设置margin
android的view中有setPadding,但是没有直接的setMargin方法.如果要在代码中设置该怎么做呢? 可以通过设置view里面的LayoutParams 设置,而这个LayoutPa ...
- Android动态设置控件宽高和padding
在开发过程中我们经常需要动态设置控件的宽高和padding.以TextView为例.如下: 布局代码 TextView的默认宽高为包裹文字,添加了一个背景颜色设置参数后更直观看到效果 <?xml ...
最新文章
- 浅谈tidb事务与MySQL事务之间的区别
- Evaluation of hybrid and non-hybrid methods for de novo assembly of nanopore reads
- SQL语言学习(四)常见函数学习
- 华为底部虚拟导航栏挡住布局
- OS中atomic的实现解析
- mybatis入门基础(二)----原始dao的开发和mapper代理开发
- 全球首发!惯性导航导论(剑桥大学)第十部分
- 进制转化进10进制数
- mysql database backup use python scripts
- 一元二次方程abc决定什么_情绪管理 - ABC理论
- paip.版本控件svn删除文件或目录后的恢复
- ip软件在生活中器到哪些作用呢?
- python中新建标签页的三种方法
- C语言参数传递——地址传递与值传递
- [概念]医学图像分割中常用的Loss function(损失函数) + 从loss处理图像分割中类别极度不均衡
- Java绘画板源码_Java 绘图板 示例源码下载(画板)
- Empirical Covariance 经验协方差 sklearn
- 一次关于Uber的通宵抬杠
- 犀牛Rhino和他的插件
- 【软考八】软件设计师下午题试题三(刷题刷题)