0

携帯電話などの小さなデバイスでアプリを実行するときに発生するレイアウトの小さな問題ですが、タブレットでは問題なくレンダリングされます。ボタンの1つが他のボタンによって「押されている」ようで、垂直にレンダリングされています。

これが問題領域のスクリーンショットです

ここに画像の説明を入力してください

私のxmlは次のとおりです。

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="8dp"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="78dp"
            android:layout_height="78dp"
            android:layout_alignParentTop="true" />

        <TextView
            android:id="@+id/txtEventNameTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Event Name"
            android:textSize="19dp"
            android:textStyle="bold"
            android:layout_below="@+id/imageView1" />

        <TextView
            android:id="@+id/txtEventName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16dp"
            android:layout_below="@+id/txtEventNameTitle" />

        <TextView
            android:id="@+id/txtEventDateTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Event Date"
            android:textSize="19dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtEventDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16dp" />

        <TextView
            android:id="@+id/txtEventTimeTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Event Time"
            android:textSize="19dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtEventTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16dp" />

        <TextView
            android:id="@+id/txtEventLocationTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Event Location"
            android:textSize="19dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtEventLocation"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16dp" />

        <TextView
            android:id="@+id/txtEventDetailsTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Event Details"
            android:textSize="19dp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtEventDetails"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="16dp" />

  <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:measureWithLargestChild="true"
        android:orientation="horizontal"
        >

     <Button
            android:id="@+id/btnAddToCal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
                        android:layout_marginBottom="20dp"

            android:text="Add to Calendar" 
            android:layout_weight="1"/>

        <Button
            android:id="@+id/btnAddToMyEvents"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Add to my Events"
            android:layout_marginTop="20dp"

            android:layout_weight="1"
            android:layout_toRightOf="@+id/btnAddToCal"

            />

        <Button
            android:id="@+id/btnSendToTwitter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Share"
            android:layout_marginTop="20dp"            
            android:layout_weight="1"
            android:minWidth="40dp"

            />
         <Button
            android:id="@+id/btnSendToMaps"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Get directions" 
                        android:layout_marginTop="20dp"

            android:layout_weight="1"
            android:layout_toRightOf="@+id/btnAddToMyEvents"

         />


   </LinearLayout>    

        <fragment
            android:id="@+id/map"
            android:layout_width="fill_parent"
            android:layout_height="300dp"
            class="com.google.android.gms.maps.SupportMapFragment"
            android:layout_marginBottom="10dp"
             />
    </LinearLayout>

</ScrollView>
4

2 に答える 2

2

以下のようにコードを変更します。weightSumボタンを設定しているのと同じように設定していないwrap_contentため、ボタンが間違った方法で表示される問題が発生します。

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:measureWithLargestChild="true"
        android:orientation="horizontal"
        android:weightSum="4">
 <Button
        android:id="@+id/btnAddToCal"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
                    android:layout_marginBottom="20dp"

        android:text="Add to Calendar" 
        android:layout_weight="1"/>

    <Button
        android:id="@+id/btnAddToMyEvents"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Add to my Events"
        android:layout_marginTop="20dp"

        android:layout_weight="1"
        android:layout_toRightOf="@+id/btnAddToCal"

        />

    <Button
        android:id="@+id/btnSendToTwitter"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Share"
        android:layout_marginTop="20dp"            
        android:layout_weight="1"
        android:minWidth="40dp"

        />
     <Button
        android:id="@+id/btnSendToMaps"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Get directions" 
                    android:layout_marginTop="20dp"

        android:layout_weight="1"
        android:layout_toRightOf="@+id/btnAddToMyEvents"

     />
</LinearLayout>   
于 2013-02-19T12:38:56.967 に答える
0

パラメータ'android:weightSum="4"'を線形レイアウトに追加します

于 2013-02-19T12:44:25.827 に答える