0

これを修正しようとするのはうんざりですが、運はありません。

Map View、シークバー、EditText で構成されたレイアウトがあります。

マップビューがスペース全体を占有しているため、EditText テキストが表示されないという問題。

重量値で遊んでみましたが、うまくいきませんでした。

あなたの助けに感謝。

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

    a:layout_height="fill_parent" >


        <com.google.android.maps.MapView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/mapview"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:apiKey="somekey"
            android:clickable="true" 

             android:layout_weight="0"
            a:layout_alignParentTop="true"
             />

       <SeekBar
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/seekBar1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"

            android:layout_marginTop="26dp"
            a:paddingLeft="10dip"
            a:paddingRight="10dip"
            a:paddingTop="30dip"
            android:max="100" >
        </SeekBar>

 <EditText
            a:id="@+id/smsBody"
            a:layout_width="0dip"
            a:layout_height="wrap_content"
            a:layout_weight="1.0"
            a:autoText="true"
            a:capitalize="sentences"
            a:hint="@string/sms_enter_message"
            a:imeOptions="actionSend|flagNoEnterAction"
            a:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
            a:maxLines="10"
            a:nextFocusRight="@+id/send_button"
            a:layout_alignParentBottom="true" />

</RelativeLayout>
4

4 に答える 4

2

MapView にレイアウトの重みを直接適用しようとしているようです。代わりに、MapView を FrameLayout などの親コンテナー内に配置し、親コンテナーに 0.7 などのレイアウト ウェイトを適用します。

于 2012-07-22T22:07:02.703 に答える
2

で要素を調整する必要があります android:layout_weight。たとえば、次のようにします。うまくいくことを願っています。

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

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="6" >

            <SeekBar
                android:id="@+id/seekBar1"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/maplayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="6" >

            <EditText
                android:id="@+id/smsBody"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:hint="test" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="3" >

            <com.google.android.maps.MapView
                android:id="@+id/map"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:apiKey="XXX" />
        </LinearLayout>

    </LinearLayout>
于 2012-07-22T22:20:53.760 に答える
1

たった 2 行の単純なコードで完了です :)

    android:layout_alignParentBottom="true"

    android:layout_above="@+id/headerRow"


<?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"
    android:background="@drawable/bg" >

    <FrameLayout
        android:id="@+id/headerRow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="HERE GOES YOUR TEXT" />
    </FrameLayout>

    <com.google.android.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/headerRow"
        android:apiKey="mykey"
        android:clickable="true" />

</RelativeLayout>

これは間違いなくあなたの仕事を完璧に終わらせるのに役立ちます.

ありがとう :)

于 2012-07-22T22:41:36.443 に答える
1

これが必要なものです。MapView または他の要素でこのプロパティを設定してみてください。

android:layout_above="@+id/.."またはandroid:layout_below="@+id/..."

そして、すべての重み属性を削除します。説明されているプロパティを使用して仕事を行うことができるため、RelativeLayout では使用できません。すべての要素がスタックにあり、レイアウト内に「詰め込まれていない」場合にlayout_weight一般的に使用されます。LinearLayout

これらのプロパティは、親レイアウトが である場合に使用され、RelativeLayoutどのレイアウトを他のレイアウトの上に配置するか、通常は全体の向きを決定します。また、それぞれ左向きまたは右向きのlayout_toLeftOfとがあります。layout_toRightOf

于 2012-07-22T22:33:45.260 に答える