Android--取得布局中指定控件的宽高
来源:互联网 发布:淘宝服务怎么申请退款 编辑:程序博客网 时间:2024/04/30 15:57
import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;public class GetWH extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); View view = getLayoutInflater().inflate(R.layout.main, null); Button button = (Button) view.findViewById(R.id.button2); int width = button.getLayoutParams().width; int height = button.getLayoutParams().height; Log.i("System.out", width + "-----" + height); }}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearlayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <Button android:id="@+id/button2" android:layout_width="80px" android:layout_height="80dp" android:text="Button" /></LinearLayout>
从结果中大家可以看出些什么呢?
- Android--取得布局中指定控件的宽高
- velocity页面取得map中指定键的值
- Android中TextView的文本内容中指定关键字高亮显示
- 如何在smartphone程序中指定textbox控件的输入法
- 在smartphone程序中指定textbox控件的输入法
- 怎样删除MSHFlexGrid控件中指定的记录
- Android布局(控件高度的确定)
- 如何取得所选字体中指定字符串的高度和宽度 并 使用
- JQuery在轮循中取得当前fieldset中指定的元素值
- C语言版GetPrivateProfileString()函数,从初始化文件中指定的条目取得字串
- 在Android Studio中指定import的先后顺序
- 找出窗体中指定控件(WINFORM && WEBFORM)
- Android-自定義控件使用(方便修改控件的風格,只修改布局文件)
- 自定义宽高比例的布局控件
- 重设布局中控件或布局的宽高
- 取得字符串中指定子字符串出现第n次的位置,效率不高,勉强可用
- Lazarus中指定将控件的事件与delphi的区别
- 定GRIDVIEW的宽高
- VC++检测VM、VPC虚拟机代码
- uva110-Meta-Loopless Sorts(没有循环的排序程序)
- Bug:Interoptype 'Microsoft.Office.Interop.Excel.WorkbookClass' cannot be embedded. Use theapplicable
- java语言中this于super关键字的区别
- 关于Mongo4J网上资料都没有提及的秘密!
- Android--取得布局中指定控件的宽高
- hibernate入门实例代码
- jsp、freemarker、velocity比较
- PHP Yii框架中使用smarty模板
- 分析android动画模块
- Android自动化测试之虚拟机中软件安装方法(四)
- 微软今天处境与6年前苹果大同小异
- NSInvocation的一种用法
- 9 个免费的云操作系统