2017-05-18 3 views
0

Mein EditText und ImageButton erscheinen nicht wegen falscher Positionierung. Fragment erfolgreich auftauchen.Android - Falsche Layout-Positionierung

Hier ist mein Layout-Ansicht Code

<ListView 
    android:id="@+id/msgListView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/form" 
    android:divider="@null" 
    android:dividerHeight="0dp" 
    android:paddingBottom="10dp" 
    android:text="Hello World" /> 

<LinearLayout 
    android:id="@+id/form" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:background="#91f1f1f1" 
    android:orientation="horizontal" 
    android:paddingBottom="2dp" > 


    <EditText 
     android:id="@+id/messageEditText" 
     android:layout_width="252dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignTop="@+id/button1" 
     android:layout_toLeftOf="@+id/sendMessageButton" 
     android:layout_weight="0.72" 
     android:ems="10" 
     android:maxHeight="80dp" /> 

    <ImageButton 
     android:id="@+id/sendMessageButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:background="@drawable/send_button" 
     android:text="d" /> 
</LinearLayout> 

Meine vollständigen Quellcode hier https://github.com/IntellijSys/AndroidChat ist.

Bitte um Rat. Vielen Dank.

Antwort

0

Ich habe es bereits mit meiner Lösung behoben.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="horizontal" 
    android:background="#e1e1e1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <ListView android:id="@+id/msgListView" 
     android:paddingBottom="10dp" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:divider="@null" 
     android:dividerHeight="0dp" 
     android:text="[email protected]/hello_world" 
     android:layout_above="@+id/form" /> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:id="@+id/form" 
     android:background="#91f1f1f1" 
     android:paddingBottom="2dp" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true"> 

     <EditText android:id="@+id/messageEditText" 
      android:layout_width="252dp" 
      android:layout_height="wrap_content" 
      android:maxHeight="80dp" 
      android:ems="10" 
      android:layout_weight="0.72" 
      android:layout_toLeftOf="@+id/sendMessageButton" 
      android:layout_alignTop="@+id/sendMessageButton" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentBottom="true" /> 

     <ImageButton android:id="@+id/sendMessageButton" 
      android:background="@drawable/send_button" 
      android:layout_width="48dp" 
      android:layout_height="48dp" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentBottom="true" /> 

    </LinearLayout> 
</RelativeLayout> 
1

enter image description here hey kann u verwenden dieses

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/bg_messages" 
    android:orientation="vertical" 
    tools:context=".MainFragment"> 

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:orientation="horizontal" 
     android:gravity="center_vertical"> 

     <EditText 
      android:id="@+id/message_input" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:hint="@string/prompt_message" 
      android:imeActionId="@+id/send" 
      android:imeActionLabel="@string/action_send" 
      android:imeOptions="actionSend" 
      android:inputType="text" 
      android:maxLines="1" 
      android:singleLine="true"/> 
     <ImageButton 
      android:id="@+id/send_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@android:drawable/ic_menu_send" 
      android:contentDescription="@string/action_send"/> 

    </LinearLayout> 

</LinearLayout> 

Sie Ihre Listview am Ort der RecycleView

+0

seit wann brauche ich RecyclerView? Alle IDs sind bereits geändert. –

+0

Sie können IDs nach Ihren Wünschen einrichten oder Sie können Ihren ListView auch an der Stelle von RecyclerView verwenden. – UltimateDevil

+0

Implementieren Sie dieses Layout in Ihren Code und ändern Sie die IDs entsprechend. – UltimateDevil

0

ändern Position von Listview wie Ihre lineare Layout

ist hinter Listview verwenden können
<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 

android:orientation="vertical"> 



<LinearLayout 

    android:id="@+id/form" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 

    android:background="#91f1f1f1" 
    android:orientation="horizontal" 
    android:paddingBottom="2dp" > 


    <EditText 
     android:id="@+id/messageEditText" 
     android:layout_width="252dp" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignTop="@+id/button1" 
     android:layout_toLeftOf="@+id/sendMessageButton" 
     android:layout_weight="0.72" 
     android:ems="10" 
     android:maxHeight="80dp" /> 

    <ImageButton 
     android:id="@+id/sendMessageButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 

     android:text="d" /> 
</LinearLayout> 
<ListView 
    android:id="@+id/msgListView" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/form" 
    android:divider="@null" 
    android:dividerHeight="0dp" 
    android:paddingBottom="10dp" 
    android:text="Hello World" /> 
    </RelativeLayout> 
+0

immer noch gleich, keine Änderungen –

0

Es gibt kein Problem in der Datei "chat_layout.xml". Ihr EditText und ImageButton wird aufgrund des AppBarLayout ausgeblendet. Sie haben app:layout_behavior="@string/appbar_scrolling_view_behavior" in ViewPager verwendet, deshalb ist Ihr Unterteil, wenn ChatFragment nicht zum ersten Mal sichtbar ist, zu versuchen, Ihr Tablayout nach oben zu ziehen.

+0

also was ist der Wert? –

Verwandte Themen