2016-03-19 18 views
0

Ich versuche, Knopf zwischen zwei Listenansicht, die vertikal ausgerichtet sind. Kann jemand bitte helfen Sie mir mit dem Problem.Ich bin sehr neu zu Android, ich habe keine Ahnung, wie man das macht.Wie füge ich einen Button zwischen Listenansicht hinzu?

<?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: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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.edkul.vimal.edkul.Library" 
    android:id="@+id/linearLayout1" 
    android:orientation="horizontal"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="@string/library" 
     android:textSize="25sp" 
     android:id="@+id/textView27" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" /> 


    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:layout_marginTop="35dp" 
     android:layout_below="@+id/textView27"> 
     <ListView 
      android:id="@+id/list_item1" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_marginRight="55dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:background="#88FF0000"> 
     </ListView> 
     <ListView 
      android:id="@+id/list_item3" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:background="#88FF0000"> 
     </ListView> 
    </LinearLayout> 
    <Button 
     android:layout_width="match_parent" 
     android:layout_below="@+id/linearLayout2" 
     android:layout_height="match_parent" 
     android:text="Button1"/> 

</RelativeLayout> 

Please find the below image as a reference.

+0

Ich denke, das ist nicht Ihr gesamter Layout-Code Einige Start-Tags fehlen. So pls plom Whole Layout-Code mit dem richtigen Format. –

+0

Wie ist Ihr Elternlayout? Bitte posten Sie die gesamte XML-Datei. Code fehlt hier. –

+0

Pls erklären mehr, wo der Knopf sein soll, den Sie zwischen Listenansicht unten oder genau zwischen beiden Listenansichten wollen. Bitte angeben. –

Antwort

2

Versuchen Sie es mit diesem.

Ersetzen Sie diesen vollständigen Code in Ihrem XML.

<?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/linearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.edkul.vimal.edkul.Library"> 

    <TextView 
     android:id="@+id/textView27" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:text="Library" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textSize="25sp" /> 


    <LinearLayout 
     android:id="@+id/linearLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/textView27" 
     android:layout_marginTop="35dp" 
     android:orientation="horizontal" 
     android:weightSum="2"> 

     <ListView 
      android:id="@+id/list_item1" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:layout_weight="1" 
      android:background="#88FF0000"></ListView> 

     <LinearLayout 
      android:id="@+id/linearLayout3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_vertical" 
      android:orientation="vertical" 
      android:weightSum="2"> 

      <Button 
       android:id="@+id/btn1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Button1" /> 

      <Button 
       android:id="@+id/btn2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Button1" /> 
     </LinearLayout> 

     <ListView 
      android:id="@+id/list_item3" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left" 
      android:layout_weight="1" 
      android:background="#88FF0000"></ListView> 
    </LinearLayout> 


</RelativeLayout> 

Es wird Sie Taste genau zwischen Listviews zeigen.

Sicher wird es Ihnen helfen.

+0

Danke für die Antwort !! Ich habe meinen Code mit diesem ersetzt, aber ich brauche zwei Schaltfläche auf dem Bildschirm. Ich brauche eine weitere Schaltfläche unter der Schaltfläche Button1 –

0

Machen Sie das Layout Orientierung als horizontale .use ersten Listenansichten: verfügbar zwischen zwei columns.Please finden die unter XML-Code

Ich möchte in den Raum zwei kleinen Knopf setzen und button als 3views in deinem Layout. Stellen Sie Höhe als übergeordnetes übergeordnetes Element für Listenansichten ein, aber umbrechen Sie den Inhalt für die Schaltfläche. Überprüfen Sie, ob es funktioniert

Verwandte Themen