下面是我對android上視圖佈局的定義。有三個組件,一個編輯區,一個按鈕和一個地圖。文本字段和按鈕將放置在位於視圖頂部的嵌套線性佈局中。地圖將顯示在編輯區下方。我的問題是在編輯區寬度。我已經指定layout_weight爲10,editfield和1爲按鈕。但是,該視圖將顯示爲以下屏幕截圖。 editfield的寬度非常小。我希望它是按鈕寬度的10倍。我怎樣才能做到這一點?layout_weight不能按預期工作編輯區域
<?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">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="10"
/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="button"/>
</LinearLayout>
<com.amap.api.maps2d.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"/>
</LinearLayout>
添加的LinearLayout weightSum至11 –