2016-12-23 2 views
0

Ich kann diese 3 Tasten und 1 Text nicht in das relative Layout einfügen. Grundsätzlich war ich Listenansicht oben und dann eine relative Ansicht unter der Listenansicht. Diese relative Ansicht besteht aus Text in der ersten Zeile und 3 Schaltflächen in der zweiten Zeile.3 Tasten und 1 Text können nicht innerhalb eines relativen Layouts platziert werden

Alles funktioniert gut, aber, wenn ich 1 EditText setzen und 3 Tasten in relativ Layout, erhalte ich Fehler java.lang.IllegalStateException: Kreis Abhängigkeiten in RelativeLayout nicht existieren kann

Kann jemand bitte helfen, wirklich zu schätzen Ihre Zeit. Dank

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="app.com.date.MainActivity" 
    android:background="@color/common_google_signin_btn_text_light_disabled"> 



    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentStart="true" 
     android:layout_above="@+id/messageBox" 
     android:id="@+id/chatroom" 
     android:stackFromBottom="true" 
     android:transcriptMode="alwaysScroll" 
     android:dividerHeight="0dp" 
     android:divider="@null" 
     android:layout_alignParentBottom="false" 
     android:layout_alignWithParentIfMissing="false" /> 

    <EditText 
     android:layout_width="match_parent" 
     android:inputType="text" 
     android:ems="10" 
     android:id="@+id/messageBox" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:freezesText="true" 
     android:textSize="12sp" 
     android:fontFamily="sans-serif" 
     android:layout_alignParentBottom="false" 
     android:layout_above="@+id/sendButton" 
     android:breakStrategy="high_quality" 
     android:layout_height="wrap_content" 
     android:background="@android:color/transparent" 
     android:paddingBottom="15dip" 
     android:paddingTop="10dip" 
     android:hint="send message" /> 



    <Button 
     android:id="@+id/galleryButton" 
     android:layout_below="@+id/messageBox" 
     android:layout_alignParentStart="false" 
     android:layout_alignParentBottom="false" 
     android:layout_width="50dip" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="false" 
     android:layout_alignParentLeft="true" /> 

    <Button 
     android:id="@+id/cameraButton" 
     android:layout_below="@+id/messageBox" 
     android:layout_alignParentBottom="false" 
     android:layout_width="50dip" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="false" 
     android:layout_marginLeft="10dip" 
     android:layout_toRightOf="@+id/galleryButton" /> 

    <Button 
     android:layout_height="wrap_content" 
     android:id="@+id/sendButton" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" 
     android:layout_marginRight="15dip" 
     android:layout_width="75dip" /> 

</RelativeLayout> 
+0

Dieser Code für mich völlig in Ordnung funktioniert. Kreisförmige Abhängigkeiten treten auf, wenn die Referenzen zweier Ansichten aufeinander abgestimmt sind. Sagen Sie Button1 ist links von Button2 und Button2 ist rechts von Button1. Dies führt zu einem zyklischen Abhängigkeitsfehler. –

+0

Dieser Code ist in Ordnung, aber ich möchte Text und 3-Taste in einem zusätzlichen relativen Layout setzen – user7327850

+0

Outter Relative Layout - Listenansicht - innere relative Layout (Text bearbeiten, 3 Tasten) - Ende des inneren relativen Layout - Ende des äußeren relativen Layouts – user7327850

Antwort

0

Sie diesen Code versuchen kann hoffen, dass diese Sie ..

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".MainActivity"> 


<ListView 
    android:id="@+id/chatroom" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/ll" 
    android:layout_alignParentBottom="false" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignParentTop="true" 
    android:layout_alignWithParentIfMissing="false" 
    android:divider="@null" 
    android:dividerHeight="0dp" 
    android:stackFromBottom="true" 
    android:transcriptMode="alwaysScroll" /> 

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

    <EditText 
     android:id="@+id/messageBox" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="false" 
     android:background="@android:color/transparent" 
     android:breakStrategy="high_quality" 
     android:ems="10" 
     android:fontFamily="sans-serif" 
     android:freezesText="true" 
     android:hint="send message" 
     android:inputType="text" 
     android:paddingBottom="15dip" 
     android:paddingTop="10dip" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:textSize="12sp" /> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <Button 
      android:id="@+id/galleryButton" 
      android:layout_width="50dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 

     <Button 
      android:id="@+id/cameraButton" 
      android:layout_width="50dp" 
      android:layout_height="wrap_content" 
      android:layout_toRightOf="@+id/galleryButton" /> 

     <Button 
      android:id="@+id/sendButton" 
      android:layout_width="75dp" 
      android:layout_height="wrap_content" 
      android:layout_alignParentEnd="true" 
      android:layout_alignParentRight="true" /> 

    </RelativeLayout> 
    </LinearLayout> 
</RelativeLayout> 
+0

Sie sind unglaublich, dieser Code arbeitete wie ein Charme. Ich habe gerade die Tastenlayoutgewichte auf .15 .15 .20 geändert, die ersten 2 Tasten erscheinen auf der linken Seite, was ich will, aber für die letzte versuche ich, die Schwerkraft nach rechts zu ändern, aber es wokring nicht, wie cn ich mich bewege letzter Knopf nach extrem rechts ... danke – user7327850

+0

willkommen bro .. wenn dies Ihnen helfen kann dann bitte akzeptieren und UPVOTE this..Thanks –

+0

willkommen, sicher wird das tun .. können Sie bitte dritte Taste nach ganz rechts bewegen, wenn alle Layout-Gewichte sind .10 – user7327850

0

Ihre gleichen Code mit wenig Modifikation Versuchen Sie helfen können. Es funktioniert gut für mich. gerade gebucht und einfachste Layout

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context="app.com.date.MainActivity" 
android:background="@color/common_google_signin_btn_text_light_disabled"> 



<ListView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:layout_above="@+id/messageBox" 
    android:id="@+id/chatroom" 
    android:stackFromBottom="true" 
    android:transcriptMode="alwaysScroll" 
    android:dividerHeight="0dp" 
    android:divider="@null" 
    android:layout_alignParentBottom="false" 
    android:layout_alignWithParentIfMissing="false" /> 

<EditText 
    android:layout_width="match_parent" 
    android:inputType="text" 
    android:ems="10" 
    android:id="@+id/messageBox" 
    android:textAppearance="@style/TextAppearance.AppCompat" 
    android:freezesText="true" 
    android:textSize="12sp" 
    android:fontFamily="sans-serif" 
    android:layout_alignParentBottom="false" 
    android:layout_above="@+id/sendButton" 
    android:breakStrategy="high_quality" 
    android:layout_height="wrap_content" 
    android:background="@android:color/transparent" 
    android:paddingBottom="15dip" 
    android:paddingTop="10dip" 
    android:hint="send message" /> 



<Button 
    android:id="@+id/galleryButton" 
    android:layout_below="@+id/messageBox" 
    android:layout_alignParentStart="false" 
    android:layout_alignParentBottom="false" 
    android:layout_width="50dip" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="false" 
    android:layout_alignParentLeft="true" /> 

<Button 
    android:id="@+id/cameraButton" 
    android:layout_below="@+id/messageBox" 
    android:layout_alignParentBottom="false" 
    android:layout_width="50dip" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="false" 
    android:layout_marginLeft="10dip" 
    android:layout_toRightOf="@+id/galleryButton" /> 

<Button 
    android:layout_height="wrap_content" 
    android:id="@+id/sendButton" 
    android:layout_width="75dip" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentEnd="true" /> 

0

ich den Code aktualisiert bitte versuchen Sie dieses

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

    <LinearLayout 
     android:id="@+id/btnLL" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" > 

     <Button 
      android:id="@+id/testbutton" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Save" /> 

     <Button 
      android:id="@+id/cancelButton" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Cancel" /> 

     <Button 
      android:id="@+id/cancelButton1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:text="Cancel" /> 

     <EditText 
      android:layout_width="100dp" 
      android:layout_height="40dp" 
      android:background="#ffffff" 
      android:text="edittext " /> 
    </LinearLayout> 

    <ListView 
     android:id="@+id/LstPeriodOptions" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/btnLL" /> 

</RelativeLayout> 
0

ich.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:id="@+id/activity_main" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin">    

       <ListView 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/chatroom" 
        android:dividerHeight="0dp" 
        android:layout_above="@+id/messageBox" 
        android:divider="@null"/> 

       <EditText 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:inputType="text" 
        android:ems="10" 
        android:id="@+id/messageBox" 
        android:textAppearance="@style/TextAppearance.AppCompat" 
        android:textSize="12sp" 
        android:fontFamily="sans-serif" 
        android:background="#eee" 
        android:paddingTop="15dp" 
        android:paddingBottom="15dp" 
        android:paddingStart="5dp" 
        android:paddingLeft="5dp" 
        android:paddingEnd="5dp" 
        android:paddingRight="5dp" 
        android:layout_above="@+id/galleryButton"     
        android:hint="send message" />    

       <Button 
        android:id="@+id/galleryButton" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
        android:text="gallery"/> 

       <Button 
        android:id="@+id/cameraButton" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:text="Camera"     
        android:layout_toStartOf="@+id/sendButton" 
        android:layout_toLeftOf="@+id/sendButton" 
        android:layout_toRightOf="@+id/galleryButton" 
        android:layout_toEndOf="@+id/galleryButton" 
        android:layout_below="@+id/messageBox"/> 

       <Button 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:id="@+id/sendButton" 
        android:text="Send" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" /> 

    </RelativeLayout> 

UI sollte nicht unerwünscht tiefer.Versuche, so einfach wie am besten zu beenden. dann wird nur UI schneller sein.

so wird Ihr Layout wie sein

enter image description here

Verwandte Themen