解决方案 »

  1.   


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:weightSum="4"
            android:gravity="center"
            android:orientation="horizontal" >        <Button
                android:id="@+id/tv_dis_result"
                android:layout_width="1dp"
                android:layout_height="wrap_content"
                android:layout_weight="3">
            </Button>
        </LinearLayout>
    </LinearLayout>这方法能实现,不过布局有点繁琐...
      

  2.   

    hi,后来我想了下,可以使用网格布局GridLayout来实现,具体是:父亲组件用GridLayout来实现,划分为1×8个单元格,让文本框占据中间6个单元格即可。不过,我好奇,XML配置文件中是否可以得到组件的宽高值,以便在孩子组件中用于设置大小。
      

  3.   

    使用weight自己调一调
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/container"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:layout_weight="3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_weight="1"
            android:background="@color/red"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
        <Button
            android:layout_weight="3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        </LinearLayout>
      

  4.   

    做不到,计算宽高的数值是在控件的onMeasure方法执行的时候确定的
      

  5.   

    嗯,知道了。还是考虑多用TableLayout和GridLayout
      

  6.   

    你用个linearlayout,设置一下比重,然后用空的textview或者button填充也可以解决啊