android百度地图 覆盖物弹出层效果

本文介绍如何使用Dialog和悬浮弹出层效果展示轮船信息,适用于手机屏幕显示,包括布局文件、代码实现及关键组件配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


一:可以使用Dialog使用悬浮弹出层效果

         手机屏幕小一般这种方式更fit

      


     dilog布局文件:

<?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="wrap_content"
    android:background="#ffffff"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#0099ff" > <!-- #d94a4a红色搭配 -->

        <ImageView
            android:id="@+id/win_close"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/close" />

        <TextView
            android:id="@+id/win_title"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1.05"
            android:gravity="center"
            android:text="轮船信息"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/default_button" />
    </LinearLayout>
    
    
    <TableLayout 
        android:id="@+id/map_shipinfo_table"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >       
        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            >
            
            <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="船舶名称:"
            android:textColor="#bbbbbb"
            android:paddingLeft="6dip"
            android:ems="4"
            />
        
           <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="BAIYUAN9HAO"
            android:textColor="#bbbbbb"
            android:paddingLeft="2dip"
            android:ems="5"
            />
           
           
           <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="船舶类型:"
            android:textColor="#bbbbbb"
            android:paddingLeft="6dip"
            android:ems="4"
            />
        
           <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="123"
            android:textColor="#bbbbbb"
            android:ems="4"
            />
           
        </TableRow>
        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            >
            
            <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="长:"
            android:textColor="#bbbbbb"
            android:paddingLeft="6dip"
            android:ems="4"
            />
        
           <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="37"
            android:textColor="#bbbbbb"
            android:paddingLeft="2dip"
            android:ems="5"
            />
           
           
           <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="宽:"
            android:textColor="#bbbbbb"
            android:paddingLeft="6dip"
            android:ems="4"
            />
        
           <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="123"
            android:textColor="#bbbbbb"
            android:ems="4"
            />
           
        </TableRow>
         
    </TableLayout>
    
    <TableLayout 
        android:layout_width="match_parent"
        android:layout_height="50dp"    
        >
         <TableRow 
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="left"
             android:gravity="left"
             android:layout_marginTop="12dp"
             android:paddingRight="5dp"
            >
            <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="船舶轨迹"
            android:layout_gravity="left"
            android:textColor="#0033FF"
            android:layout_marginLeft="6dip"
            android:ems="9"
            />
         </TableRow>
    </TableLayout>
    
</LinearLayout>
           
public class ShipInfoDialog {
     
	private Dialog dialog;	
  	  Activity _mActivitygb;
	public ShipInfoDialog(final Activity _mActivity,String _shipinfo) {
		try{
		dialog = new Dialog(_mActivity, R.style.mask_dialog);
		final LinearLayout popView = (LinearLayout) LayoutInflater.
				from(_mActivity).inflate(com.lc.main.R.layout.map_shipinfo_dialogview, null);
		
		_mActivitygb = _mActivity;
		// 关闭按钮
		ImageView viewClose = (ImageView) popView.findViewById(R.id.win_close);
		viewClose.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				hide();
			}
		});
		
		dialog.setContentView(popView, 
				new LinearLayout.LayoutParams(
						LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		dialog.setFeatureDrawableAlpha(Window.FEATURE_OPTIONS_PANEL, 0);
		
		Button setok = (Button) popView.findViewById(R.id.setok);
		setok.setOnClickListener(new OnClickListener()
		{
			public void onClick(View v) {			
			}		
		});
		    //eidt(_shipinfo,popView,_mActivity);	
		}
		 catch (Exception e) {
				System.out.println(e);
			}
	}
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值