2016-05-04 3 views
0

Hey People У меня проблема с тем, что когда список растет, он идет за editText ... Я не хочу, чтобы он заходил за представление. Я хочу, чтобы он оставался над editText. Не могли бы вы мне помочь? Я ценю вашу помощь.Почему listVIew идет за EditText?

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

    <ListView 
     android:id="@+id/list_view" 
     android:layout_width="match_parent" 
     android:layout_weight="1" 
     android:layout_height="0dp" 
     android:paddingBottom="10dp"></ListView> 

    <GridLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:columnCount="2"> 

     <EditText 
      android:id="@+id/edit_text" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_column="0" 
      android:layout_row="0" 
      android:layout_gravity="fill_horizontal|bottom" 
      android:hint="Type text here..." 
      android:maxLines="3" 
      android:scrollbars="vertical" 
      android:maxEms="10"/> 

     <Button 
      android:id="@+id/button" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_column="1" 
      android:layout_row="0" 
      android:text="Send" 
      android:layout_gravity="bottom" 
      android:onClick="insertTo" 
      /> 
    </GridLayout> 
</LinearLayout> 

enter image description here

+0

Его не происходит за 'editText', его последний предел текст для прокрутки в конце границы списка. – Pankaj

+0

это не позади. Это поведение по умолчанию, так как ваш основной макет - это линейный макет, а дочерние элементы выравниваются по вертикали. Это показано так, что из-за paddingBottom в listview –

ответ

1
<ListView 
    android:id="@+id/list_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="10dp"></ListView> 
1

Попробуйте это Изменена вес взглядов

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

    <ListView 
     android:id="@+id/list_view" 
     android:layout_width="match_parent" 
     android:layout_weight="0.97" 
     android:layout_height="0dp" 
     android:paddingBottom="10dp"></ListView> 

    <GridLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.03" 
     android:columnCount="2"> 

     <EditText 
      android:id="@+id/edit_text" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_column="0" 
      android:layout_row="0" 
      android:layout_gravity="fill_horizontal|bottom" 
      android:hint="Type text here..." 
      android:maxLines="3" 
      android:scrollbars="vertical" 
      android:maxEms="10"/> 

     <Button 
      android:id="@+id/button" 
      android:layout_height="wrap_content" 
      android:layout_width="wrap_content" 
      android:layout_column="1" 
      android:layout_row="0" 
      android:text="Send" 
      android:layout_gravity="bottom" 
      android:onClick="insertTo" 
      /> 
    </GridLayout> 
</LinearLayout> 
0

Снимите:android:layout_weight="1" из ListView

Он выглядит следующим образом:

<ListView 
android:id="@+id/list_view" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:paddingBottom="10dp"></ListView> 
0

Используйте RelativeLayout в качестве корневой точки зрения вашего XML.

Дайте GridLayout id и сделайте его alignParentBottom = "true". Держите ListView выше GridLayout. Что это должно выглядеть это:

<ListView 
     android:id="@+id/list_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/gridviewItem"> 
</ListView> 

and GridView item should look like: 

<GridLayout 
     android:id="@+id/gridviewItem" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.03" 
     android:columnCount="2"> 

// Сетка Просмотр элементов />

надеюсь, что это помогает ....