我正在研究android项目,在其中我需要绘制如下所示的UI。我需要将android屏幕分成两半。在上半部分,我需要显示google mps。在下半部分,我需要在任何人单击Google Maps时显示用户信息。上半部分已完成,对我有用。

问题陈述:-

我在为下半部分设计UI时遇到了麻烦。以下UI的main.xml file应该是什么。每当我单击markers on the Map时,Android屏幕的下半部都会显示information。下面是我在油漆上做的设计
 其中包含图片和android屏幕下半部分的用户信息。



这是我目前作为main.xml file所拥有的,需要对其进行修改以使其类似于上图。

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

    <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:apiKey="0vAX8Xe9xjo5gkFNEEIH7KdHkNZNJWNnsjUPKkQ"
        android:clickable="true"
        android:enabled="true" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:text="TextView" />

</LinearLayout>

最佳答案

您可以尝试以下方法:

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

    <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:apiKey="0vAX8Xe9xjo5gkFNEEIH7KdHkNZNJWNnsjUPKkQ"
        android:clickable="true"
        android:state_enabled="true" />

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <LinearLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="0.7"
            android:orientation="vertical">

            <ImageView
                android:src="@drawable/icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="45dp"
            />

     </LinearLayout>

     <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical">

       <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="45dp"
            android:text="Name:" />

       <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Gender:" />

       <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Distance:" />

       <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Latitude:" />

       <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Longitude:" />
    </LinearLayout>

  </LinearLayout>

</LinearLayout>




希望这就是您想要的。

关于java - 在屏幕的下半部分显示图像和用户信息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11927513/

10-11 22:19
查看更多