2017-09-17 36 views
0

設置高度後如何去除上面的空間? The space between the upload button and country text input我如何擺脫上傳按鈕和國家textinput之間的空間?

我這是怎麼設定的圖像height.Am試圖在包括一些項目的卡片來顯示圖像,但如果高度設置爲包裹的內容,在下面圈文字的圖像。基本上我想擺脫的空間,也將高度設置爲160dp

imageview = (ImageView) view.findViewById(R.id.imageView_pic); 
    imageview.getLayoutParams().height = 160; 

我的XML是

<LinearLayout 
    android:id="@+id/email_login_form" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:id="@+id/layout_first_name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:text="@string/first_name" 
      android:textColor="#000000" 
      android:textSize="20sp" /> 

     <EditText 
      android:id="@+id/first_Name" 
      style="@style/edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="text" /> 
    </LinearLayout> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:text="@string/last_name" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/last_Name" 
     style="@style/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="text" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:text="@string/farmer_organisation" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/farmer_organisation" 
     style="@style/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="text" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:text="@string/acreage" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/acreage" 
     style="@style/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="number" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:text="@string/gender" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    <Spinner 
     android:id="@+id/genderSpinner" 
     style="@style/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:entries="@array/gender" /> 


    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:text="@string/crop" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    <Spinner 
     android:id="@+id/cropSpinner" 
     style="@style/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:entries="@array/crops" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:text="@string/country" 
     android:textColor="#000000" 
     android:textSize="20sp" /> 

    <Spinner 
     android:id="@+id/countrySpinner" 
     style="@style/edit_text" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:entries="@array/countries" /> 

    <LinearLayout 
     android:id="@+id/layout_district" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="@string/district" 
      android:textColor="#000000" 
      android:textSize="20sp" /> 

     <Spinner 
      android:id="@+id/districtSpinner" 
      style="@style/edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:entries="@array/district" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/layout_sub_county" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="@string/sub_county" 
      android:textColor="#000000" 
      android:textSize="20sp" /> 

     <EditText 
      android:id="@+id/sub_county" 
      style="@style/edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="text" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/layout_parish" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="@string/parish" 
      android:textColor="#000000" 
      android:textSize="20sp" /> 

     <EditText 
      android:id="@+id/parish" 
      style="@style/edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="text" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/layout_village" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="16dp" 
      android:text="@string/village" 
      android:textColor="#000000" 
      android:textSize="20sp" /> 

     <EditText 
      android:id="@+id/village" 
      style="@style/edit_text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:inputType="text" /> 
    </LinearLayout> 

    <ImageView 
     android:id="@+id/imageView_pic" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:adjustViewBounds="true" 
     android:scaleType="fitXY" /> 

    <Button 
     android:id="@+id/btn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="10dp" 
     android:background="@drawable/my_button" 
     android:text="@string/upload_photo" 
     android:textColor="@android:color/white" /> 

    <Button 
     android:id="@+id/uploadButton" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="15dp" 
     android:background="@drawable/my_button" 
     android:text="@string/submit" 
     android:textColor="@android:color/white" 
     android:textStyle="bold" /> 

</LinearLayout> 

+2

您的XML僅顯示圖像視圖,因此無法看到您的錯誤 – Kuffs

+1

在您的屏幕截圖中,ImageView在哪裏?請發佈完整的XML。 –

+0

我現在已經添加了整個xml – Raphael

回答

0

可以在垂直方向使用線性佈局,然後設計結構,它會幫助你擺脫空間,並向我展示整個代碼,以瞭解你的代碼結構爲什麼要插入空間。

+0

我已經添加了整個XML。這個空間是由於我設置爲160的高度而造成的。我希望高度保持不變,但也要擺脫空間 – Raphael