我想在我的應用程序上放置一個地圖,然後在其上添加一個文本字段和一個按鈕。以下是我的xml文件。啓動此應用程序後,地圖顯示在屏幕上,但文本字段和按鈕不存在。即使我刪除地圖,它們也不會顯示。我在這裏錯過了什麼?當我使用0dp佈局寬度時,layout_weight在android上不起作用
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context="com.lenovo.mds.lenovopoc.MainActivity">
<com.amap.api.maps2d.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.70" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="button"
android:layout_weight="0.70"/>
</LinearLayout>
LinearLayout支持android:layout_weight –
RelativeLayout不支持layout_weight;使用LinearLayout – akash93
是的,你必須使用線性佈局,如果你想使用重量 – Saveen