【发布时间】:2016-06-03 02:17:46
【问题描述】:
目前我正在创建巴士票簿应用程序。在这个应用程序中,我想将座位设置为 web 服务的响应。所以问题是,如果左侧一个卧铺座位和右侧座位,那么我如何安排座位,如下图所示。 目前我正在使用gridview,但我不知道如何实现。 以及如何动态设置。请建议是否使用其他布局。
下面是我使用的一些代码
seatLayout.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" >
<RelativeLayout
android:id="@+id/seatLayoutScroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottomBarSeatSelection"
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="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5.0dip"
android:layout_marginTop="5.0dip"
android:background="@color/white" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/bus_seat_indicator_layout" />
</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:paddingBottom="5.0dp"
android:paddingRight="5.0dp"
android:layout_marginTop="10.0dip">
<GridView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/driver"
android:layout_margin="4dp"
android:horizontalSpacing="10dp"
android:verticalSpacing="10dp"
android:columnWidth="90dp"
android:gravity="center"
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_marginRight="20.0dp"
android:layout_marginBottom="5.0dp"
android:layout_alignRight="@+id/gridView1"
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:visibility="invisible" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/bottomBarSeatSelection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white" >
<include
android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/bus_seat_bottom_layout" />
</RelativeLayout>
</RelativeLayout>
使用这个我实现了以下输出
但我不知道如何获得第一张图片。
【问题讨论】:
-
如果有人投反对票,请解释你投反对票的原因,以便下次我能关心。
-
很可能您没有发布任何代码。这里有些人是混蛋,需要知道在点击之前冷静下来。
-
我认为你可以将 RecyclerView 与 StaggeredGridLayoutManager 一起使用
-
是座位按钮,我建议使用相对布局。在我看来,它真的很容易使用并且比 Grid 更好
-
请发布您的代码,以便我们知道您离您想要实现的目标还有多远。