2016-04-25 6 views
-1

je veux créer la mise en page de réservation de billets de bus dans mon application. J'ai créé la disposition mais l'arrangement de siège n'est pas venu approprié. ci-dessous est l'image. Je veux juste la mise en page assise autre élément est propre in this seat layout not proper i want to seat layout same as paytm bus ticket layoutproblème dans la disposition de siège de bus dans android

seat_selection_screen.xml

<?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" > 

    <include 
     android:id="@+id/header" 
     layout="@layout/common_header_with_sub_title" /> 

    <RelativeLayout 
     android:id="@+id/busDeckSelectionLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="45.0dip" 
     android:layout_below="@+id/header" > 

     <RelativeLayout 
      android:id="@+id/busDeckSelectionButtons" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerInParent="true" 
      android:background="#ffeeeeee" > 

      <Button 
       android:id="@+id/lowerDeck" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:background="@drawable/left_button" 
       android:text="@string/lower" 
       android:textColor="@color/black" 
       android:textSize="12.0sp" /> 

      <Button 
       android:id="@+id/upperDeck" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_toRightOf="@+id/lowerDeck" 
       android:background="@drawable/right_button" 
       android:text="@string/upper" 
       android:textColor="@color/black" 
       android:textSize="12.0sp" /> 
     </RelativeLayout> 
    </RelativeLayout> 

    <View 
     android:id="@+id/busDeckSelectionMargin" 
     android:layout_width="fill_parent" 
     android:layout_height="1.0dip" 
     android:layout_below="@+id/busDeckSelectionLayout" 
     android:background="#ffdddddd" /> 

    <RelativeLayout 
     android:id="@+id/seatSelectionHeader" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/busDeckSelectionMargin" > 

     <RelativeLayout 
      android:id="@+id/seatsLayout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_centerVertical="true" 
      android:layout_marginLeft="5.0dip" 
      android:layout_marginTop="5.0dip" > 

      <TextView 
       android:id="@+id/seatsSelectedText" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:text="@string/seats_selected" 
       android:textColor="@color/black" 
       android:textSize="12.0sp" /> 

      <TextView 
       android:id="@+id/seatsSelected" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_below="@+id/seatsSelectedText" 
       android:layout_marginTop="10.0dip" 
       android:textColor="@color/black" 
       android:textSize="14.0sp" /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:id="@+id/fareLayout" 
      android:layout_width="wrap_content" 
      android:layout_height="40.0dip" 
      android:layout_alignParentRight="true" 
      android:layout_centerVertical="true" 
      android:layout_toRightOf="@+id/seatsLayout" 
      android:background="@layout/fare_seat_selection_background" > 

      <TextView 
       android:id="@+id/rsText" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentLeft="true" 
       android:layout_centerVertical="true" 
       android:layout_marginBottom="10.0dip" 
       android:layout_marginLeft="5.0dip" 
       android:layout_marginTop="10.0dip" 
       android:text="@string/rupees" 
       android:textColor="@color/black" 
       android:textSize="18.0sp" /> 

      <TextView 
       android:id="@+id/fare" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:layout_marginBottom="10.0dip" 
       android:layout_marginRight="5.0dip" 
       android:layout_marginTop="10.0dip" 
       android:textColor="@color/black" 
       android:textSize="18.0sp" /> 
     </RelativeLayout> 
    </RelativeLayout> 

    <View 
     android:id="@+id/seatSelectionHeaderMargin" 
     android:layout_width="fill_parent" 
     android:layout_height="1.0dip" 
     android:layout_below="@+id/seatSelectionHeader" 
     android:background="#ffdddddd" /> 

    <RelativeLayout 
     android:id="@+id/seatLayoutScroll" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/bottomBarSeatSelection" 
     android:layout_below="@+id/seatSelectionHeaderMargin" 
     android:background="@color/white" > 

     <RelativeLayout 
      android:id="@+id/scrollableLayout" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

      <RelativeLayout 
       android:id="@+id/seatLegendLayout" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="5.0dip" 
       android:layout_marginTop="5.0dip" > 

       <RelativeLayout 
        android:id="@+id/availableImageLayout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" > 

        <ImageView 
         android:id="@+id/availableImage" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_marginLeft="10.0dip" 
         android:rotation="90.0" 
         android:src="@drawable/seat_layout_tab_nor_avl" /> 

        <TextView 
         android:id="@+id/availableText" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerVertical="true" 
         android:layout_marginLeft="5.0dip" 
         android:layout_toRightOf="@+id/availableImage" 
         android:text="@string/available" 
         android:textSize="12.0sp" /> 
       </RelativeLayout> 

       <RelativeLayout 
        android:id="@+id/bookedImageLayout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toRightOf="@+id/availableImageLayout" > 

        <ImageView 
         android:id="@+id/bookedImage" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentLeft="true" 
         android:layout_centerVertical="true" 
         android:layout_marginLeft="10.0dip" 
         android:rotation="90.0" 
         android:src="@drawable/seat_layout_tab_nor_bkd" /> 

        <TextView 
         android:id="@+id/bookedText" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerVertical="true" 
         android:layout_marginLeft="5.0dip" 
         android:layout_toRightOf="@+id/bookedImage" 
         android:text="@string/booked" 
         android:textSize="12.0sp" /> 
       </RelativeLayout> 

       <RelativeLayout 
        android:id="@+id/selectedImageLayout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toRightOf="@+id/bookedImageLayout" > 

        <ImageView 
         android:id="@+id/selectedImage" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="10.0dip" 
         android:rotation="90.0" 
         android:src="@drawable/seat_layout_tab_nor_std" /> 

        <TextView 
         android:id="@+id/selectedText" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerVertical="true" 
         android:layout_marginLeft="5.0dip" 
         android:layout_toRightOf="@+id/selectedImage" 
         android:text="@string/selected" 
         android:textSize="12.0sp" /> 
       </RelativeLayout> 

       <RelativeLayout 
        android:id="@+id/ladiesImageLayout" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toRightOf="@+id/selectedImageLayout"> 

        <ImageView 
         android:id="@+id/ladiesImage" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="10.0dip" 
         android:rotation="90.0" 
         android:src="@drawable/seat_layout_tab_nor_lad_avl" /> 

        <TextView 
         android:id="@+id/ladiesText" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerVertical="true" 
         android:layout_marginLeft="5.0dip" 
         android:layout_toRightOf="@+id/ladiesImage" 
         android:text="@string/ladies" 
         android:textSize="12.0sp" /> 
       </RelativeLayout> 
      </RelativeLayout> 

      <RelativeLayout 
       android:id="@+id/seatLayoutLowerMain" 
       android:layout_width="wrap_content" 
       android:layout_height="fill_parent" 
       android:layout_below="@+id/seatLegendLayout" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="10.0dip" 
       android:background="@layout/seat_layout_border" 
       android:paddingBottom="5.0dp" 
       android:paddingRight="5.0dp" > 

       <GridView 
        android:id="@+id/gridView1" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_below="@+id/driver" 
        android:layout_margin="4dp" 
        android:columnWidth="100dp" 
        android:gravity="center" 
        android:numColumns="4" 
        android:stretchMode="columnWidth" > 
       </GridView> 

       <RelativeLayout 
        android:id="@+id/driver" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignRight="@+id/gridView1" 
        android:layout_marginRight="20.0dp" 
        android:layout_marginTop="5.0dp" 
        android:background="@drawable/steering_icon" 
        android:orientation="horizontal" > 
       </RelativeLayout> 
      </RelativeLayout> 

      <RelativeLayout 
       android:id="@+id/seatLayoutUpper" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/seatLegendLayout" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="10.0dip" 
       android:background="@layout/seat_layout_border" 
       android:visibility="invisible" /> 
     </RelativeLayout> 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/bottomBarSeatSelection" 
     android:layout_width="fill_parent" 
     android:layout_height="49.0dip" 
     android:layout_alignParentBottom="true" 
     android:background="@color/white" > 

     <Button 
      android:id="@+id/doneButton" 
      android:layout_width="160.0dip" 
      android:layout_height="48.0dip" 
      android:layout_alignParentLeft="true" 
      android:layout_marginTop="1.0dip" 
      android:background="@drawable/selector_red_btn" 
      android:text="@string/done" 
      android:textColor="@color/white" 
      android:textSize="18.0sp" /> 

     <Button 
      android:id="@+id/cancelButton" 
      android:layout_width="160.0dip" 
      android:layout_height="48.0dip" 
      android:layout_alignParentRight="true" 
      android:layout_marginTop="1.0dip" 
      android:background="@drawable/selector_black_btn" 
      android:text="@string/goBack" 
      android:textColor="@color/white" 
      android:textSize="18.0sp" /> 
    </RelativeLayout> 

</RelativeLayout> 

i want this type of layout for seat

+0

Je propose u à utiliser GridView –

+0

je l'ai déjà utilisé gridview –

+0

Vous voulez dire que vous voulez le fixer comme vous l'avez indiqué dans Second Screen Shot droit? –

Répondre

0

Vous pouvez donner des propriétés telles que android:verticalSpacing et android:horizontalSpacing en XML GridView et fournir les espacement selon votre condition.

Suivez ceci.

<GridView 
    android:id="@+id/gridView1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/driver" 
    android:layout_margin="4dp" 
    android:columnWidth="100dp" 
    android:gravity="center" 
    android:horizontalSpacing="10dp"  // space between two items (horizontal) 
    android:verticalSpacing="10dp"  // space between two rows (vertical) 
    android:numColumns="4" 
    android:stretchMode="columnWidth" > 
</GridView>