您的位置:首页 > 其它

动态改变控件大小

2016-09-01 10:32 267 查看
区分父布局
rootLayout = (LinearLayout) findViewById(R.id.test_root_linearlayout); 
        LinearLayout.LayoutParams rootLinaerParams = new LinearLayout.LayoutParams( 
                100, 100); 
        ViewGroup.LayoutParams rootGroupParams = new LinearLayout.LayoutParams( 
                100, 100); 
        RelativeLayout.LayoutParams rootRelativeParams = new RelativeLayout.LayoutParams( 
                100, 100); 
        TextView testView = new TextView(this); 
        testView.setText("根布局测试动态添加组件并设置其大小"); 
        testView.setLayoutParams(rootGroupParams); 
        rootLayout.addView(testView); 
        
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: