2016-09-10 60 views
0

我遇到支持庫的Gridlayout問題。我要讓列平等的,我使用grid:layout_columnWeigh這一點,但由於某種原因列不看等於:Gridlayout錯誤的單元格寬度調整

enter image description here

activity_maps.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:grid="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.v7.widget.GridLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="3" 
     grid:alignmentMode="alignMargins" 
     grid:columnCount="4" 
     grid:columnOrderPreserved="false" 
     grid:orientation="horizontal" 
     grid:rowOrderPreserved="false" 
     grid:useDefaultMargins="false"> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_lat1" 
      grid:layout_columnWeight="11" 
      android:layout_width="63dp"> 

      <EditText 
       android:id="@+id/lat1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="lat 1" 
       android:inputType="numberDecimal|numberSigned" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_long1" 
      grid:layout_columnWeight="1"> 

      <EditText 
       android:id="@+id/long1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="long 1" 
       android:inputType="numberDecimal|numberSigned" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_lat2" 
      grid:layout_columnWeight="1"> 

      <EditText 
       android:id="@+id/lat2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="lat 2" 
       android:inputType="numberDecimal|numberSigned" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_long2" 
      grid:layout_columnWeight="1" 
      > 

      <EditText 
       android:id="@+id/long2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="long 2" 
       android:inputType="numberDecimal|numberSigned" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_lat3" 
      grid:layout_columnWeight="1"> 

      <EditText 
       android:id="@+id/lat3" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="lat 3" 
       android:inputType="numberDecimal|numberSigned" 
       grid:layout_columnWeight="1" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_long3" 
      grid:layout_columnWeight="1"> 

      <EditText 
       android:id="@+id/long3" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="long 3" 
       android:inputType="numberDecimal|numberSigned" 
       grid:layout_columnWeight="1" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_lat4" 
      grid:layout_columnWeight="1"> 

      <EditText 
       android:id="@+id/lat4" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="lat 4" 
       android:inputType="numberDecimal|numberSigned" /> 
     </android.support.design.widget.TextInputLayout> 

     <android.support.design.widget.TextInputLayout 
      android:id="@+id/layout_long4" 
      grid:layout_columnWeight="1" 
      android:layout_width="wrap_content"> 

      <EditText 
       android:id="@+id/long4" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:hint="long 4" 
       android:inputType="numberDecimal|numberSigned" /> 
     </android.support.design.widget.TextInputLayout> 

     <Button 
      android:id="@+id/build_polygon" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Build Polygon" 
      grid:layout_columnSpan="2" /> 
    </android.support.v7.widget.GridLayout> 

    <fragment xmlns:map="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     tools:context="com.geobox.MapsActivity" /> 
</LinearLayout> 

回答

0

嘗試添加下面所有子組件中的行如下

grid:layout_columnWeight="1" 
相關問題