6

Voglio mettere un pulsante normale tra due layout come mostrato nell'immagine.Come inserire un pulsante tra due layout

Non voglio utilizzare il pulsante flottante e il layout del coordinatore.

E 'possibile tramite un layout relativo?

Demo Immagine no image description

Sto usando seguente file XML per farlo.

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

    <fragment 
     android:id="@+id/mapForPlannedRide" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="3.5" /> 

    <LinearLayout 
     android:id="@+id/planned_detail_layout" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="6.5" 
     android:background="@color/text_white" 
     android:orientation="vertical" 
     android:weightSum="10" > 

     <LinearLayout 
      android:id="@+id/departure_layout" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="2.5" 
      android:gravity="center_vertical" 
      android:orientation="horizontal" 
      android:paddingLeft="20dp" 
      android:paddingRight="20dp" > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/passenger" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:paddingLeft="5dp" > 

       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/departure" 
        android:textSize="@dimen/text_size17sp" /> 

       <TextView 
        android:id="@+id/departure" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="dfg ddfghd dfdg" 
        android:textSize="@dimen/text_size14sp" /> 
      </LinearLayout> 
     </LinearLayout> 

     <View 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight=".03" 
      android:background="@color/line_color" /> 

     <LinearLayout 
      android:id="@+id/destination_layout" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="2.5" 
      android:gravity="center_vertical" 
      android:orientation="horizontal" 
      android:paddingLeft="20dp" 
      android:paddingRight="20dp" > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/passenger" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:paddingLeft="5dp" > 

       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/destination" 
        android:textSize="@dimen/text_size17sp" /> 

       <TextView 
        android:id="@+id/destination" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Dilshad Garden Delhi" 
        android:textSize="@dimen/text_size14sp" /> 
      </LinearLayout> 
     </LinearLayout> 

     <View 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight=".03" 
      android:background="@color/line_color" /> 

     <LinearLayout 
      android:id="@+id/date_time_layout" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1.5" 
      android:gravity="center_vertical" 
      android:orientation="horizontal" 
      android:paddingLeft="20dp" 
      android:paddingRight="20dp" > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/passenger" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:paddingLeft="5dp" > 

       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/date_time" 
        android:textSize="@dimen/text_size17sp" /> 

       <TextView 
        android:id="@+id/date_time" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="10:00 a.m." 
        android:textSize="@dimen/text_size14sp" /> 
      </LinearLayout> 
     </LinearLayout> 

     <View 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight=".03" 
      android:background="@color/line_color" /> 

     <LinearLayout 
      android:id="@+id/chosen_vehicle_layout" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1.5" 
      android:gravity="center_vertical" 
      android:orientation="horizontal" 
      android:paddingLeft="20dp" 
      android:paddingRight="20dp" > 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/passenger" /> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical" 
       android:paddingLeft="5dp" > 

       <TextView 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/chosen_vehicle" 
        android:textSize="@dimen/text_size17sp" /> 

       <TextView 
        android:id="@+id/chosen_vehicle" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Dus One" 
        android:textSize="@dimen/text_size14sp" /> 
      </LinearLayout> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 
+0

qual è il problema di allineamento di programmazione? – thepoosh

+0

ho provato ma non ne ho idea. –

+0

Usa RelativeLayout e dal menu di progettazione trascina l'immagine tra i due layout, è semplice se condividi il tuo codice, quindi lo farò e te lo darò. –

risposta

2

Ho provato questo controllo sotto il codice utilizzando RelativeLayout:

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

    <fragment 
     android:id="@+id/mapForPlannedRide" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="180dp" /> 

    <LinearLayout 
     android:id="@+id/departure_layout" 
     android:layout_width="match_parent" 
     android:layout_height="80dp" 
     android:layout_below="@+id/mapForPlannedRide" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/passenger" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="5dp"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/departure" 
       android:textSize="@dimen/text_size17sp" /> 

      <TextView 
       android:id="@+id/departure" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="dfg ddfghd dfdg" 
       android:textSize="@dimen/text_size14sp" /> 
     </LinearLayout> 
    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".03" 
     android:background="@color/line_color" /> 

    <LinearLayout 
     android:id="@+id/destination_layout" 
     android:layout_width="match_parent" 
     android:layout_height="80dp" 
     android:layout_below="@+id/departure_layout" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/passenger" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="5dp"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/destination" 
       android:textSize="@dimen/text_size17sp" /> 

      <TextView 
       android:id="@+id/destination" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Dilshad Garden Delhi" 
       android:textSize="@dimen/text_size14sp" /> 
     </LinearLayout> 
    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".03" 
     android:background="@color/line_color" /> 

    <LinearLayout 
     android:id="@+id/date_time_layout" 
     android:layout_width="match_parent" 
     android:layout_height="80dp" 
     android:layout_below="@+id/destination_layout" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/passenger" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="5dp"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/date_time" 
       android:textSize="@dimen/text_size17sp" /> 

      <TextView 
       android:id="@+id/date_time" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="10:00 a.m." 
       android:textSize="@dimen/text_size14sp" /> 
     </LinearLayout> 
    </LinearLayout> 

    <View 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight=".03" 
     android:background="@color/line_color" /> 

    <LinearLayout 
     android:id="@+id/chosen_vehicle_layout" 
     android:layout_width="match_parent" 
     android:layout_height="80dp" 
     android:layout_below="@+id/date_time_layout" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/passenger" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="5dp"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="@string/chosen_vehicle" 
       android:textSize="@dimen/text_size17sp" /> 

      <TextView 
       android:id="@+id/chosen_vehicle" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="Dus One" 
       android:textSize="@dimen/text_size14sp" /> 
     </LinearLayout> 
    </LinearLayout> 

    <ImageView 
     android:layout_width="100dp" 
     android:layout_height="50" 
     android:layout_alignParentBottom="false" 
     android:layout_alignParentRight="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginRight="20dp" 
     android:layout_marginTop="150dp" 
     android:src="@android:drawable/ic_reminder" /> 

</RelativeLayout> 
+0

ora che è un layout pesante ... – thepoosh

+1

Sì, è ma ha una soluzione alla fine. –

+0

quale problema stai affrontando ora? @Dev Sharma –