10

Tôi có một EditText với một gợi ý nổi nhưng tôi đã tự hỏi làm thế nào tôi sẽ làm giảm không gian giữa các gợi ý nổi và hộp EditText.Làm cách nào để bạn giảm không gian giữa gợi ý editText nổi và hộp editText trong Android?

Ngay bây giờ giao diện người dùng của tôi trông giống như http://imgur.com/9hQzzx4 và tôi muốn giảm khoảng trống giữa gợi ý nổi "Tiêu đề" và hộp EditText.

Dưới đây là đoạn code để file xml của tôi

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:minHeight="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" > 

    </android.support.v7.widget.Toolbar> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="16dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp"> 

     <EditText 
      style="@style/Widget.AppCompat.EditText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textSize="40dp" 
      android:hint="Title"/> 

    </android.support.design.widget.TextInputLayout> 

    <android.support.design.widget.TextInputLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp"> 

     <EditText 
      style="@style/Widget.AppCompat.EditText" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textSize="32dp" 
      android:hint="Details"/> 

    </android.support.design.widget.TextInputLayout> 

</LinearLayout> 
+0

Tôi gặp vấn đề tương tự. Bạn đã giải quyết nó? –

Trả lời

17

Chỉ cần thiết lập thuộc tính paddingTop vào yếu tố EditText.

<android.support.design.widget.TextInputLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <EditText 
     android:id="@+id/place_name" 
     android:inputType="text" 
     android:hint="@string/name" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="0dp"/> 

</android.support.design.widget.TextInputLayout> 
+6

không hoạt động .... – jyomin

+1

Đã làm việc cho tôi –

+0

đã làm việc cho tôi ... –

Các vấn đề liên quan