我看了下CSDN博客中的文章,然后代码如下:
    在OnGreat中对某一个TextView操作
    final TextView widget79 = (TextView) findViewById(R.id.widget79);
    AbsoluteLayout.LayoutParams linearParams = (AbsoluteLayout.LayoutParams)widget79.getLayoutParam();      
    linearParams.height = 70;       
    widget79.setLayoutParams(linearParams); 这样程序运行会报错关闭,屏蔽以上代码就正常
另外,怎么设置绝对位置?

解决方案 »

  1.   

    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    int screenWidth = dm.widthPixels;
    int screenHeight = dm.heightPixels;
    Button mButtonLeft = (Button)findViewById(R.id.button01);
    Button mButtonRight = (Button)findViewById(R.id.button02);
    mButtonLeft.setWidth(screenWidth / 3);
    mButtonRight.setWidth((screenWidth * 2) / 3); 
      

  2.   

    http://blog.csdn.net/ch_984326013/article/details/6618680可以去看下这篇文章。动态设置表格,也就是动态设置TextView控件!
      

  3.   


    final TextView widget79 = (TextView) findViewById(R.id.widget79) ,这种写在xml里面的 View 是不能控制其在screen上的位置吧。
    只能new 一个新的view ,然后指定它的位置,再用layout的 addView 方法把它添加到layout中。
      

  4.   

    即是说不能在xml中先添加一个控件,比如textview
    然后再在OnGreat中设置其属性,大小位置等?
      

  5.   

    好像只有绝对布局才行。
    AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(w, h, x, y);
    mLayout.updateViewLayout(mLayoutScrollView, params);