0

Android XML レイアウト プレビューアが XML レイアウトの正確な表現に近いものを提供しないという大きな問題があります。レイアウトは実行時に問題なく表示されます。これは単なるプレビューアです。

XML の例を次に示します。

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/sign_up_accountexists"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:gravity="center"
        android:text="You already have an account. Please sign in, or select &apos;forgot password&apos;."
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#ffffffff" />

    <LinearLayout
        android:layout_width="350dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/sign_up_accountexists"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="30dp" >

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Sign In" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="Forgot Password" />

    </LinearLayout>

    <TextView
        android:id="@+id/sign_up_differentaddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:text="Sign up using a different address"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#ffffffff" />

</RelativeLayout>

ここでは、ボタンを含む LinearLayout が明らかに sign_up_accountexists の下にあり、プログラムの実行時に表示されます。しかし、Eclipseは次のことを示しています:

【ボタン】

[sign_up_accountexists]

[sign_up_differentaddress]

本当に奇妙なことは、_differentaddress を削除すると、他の 2 つが正しく反転することです。プレビューアを機能させることは本当に役に立ちます。

私の質問は 2 つあります。(1) プレビューアをつまずかせる可能性のある XML で間違っていることはありますか? (2) 人々は一般的にプレビューアを使用しますか? これは素晴らしいアイデアですが、バグがあることが一般的に知られている場合は、(しぶしぶ) 回避します。

1 つの注意: LinearLayout には android:layout_below="@+id/sign_up_accountexists" があります。Eclipse はそこにプラス記号を入れましたが、これは間違っていると思いました。ただし、削除しても違いはありません。

私の人生のすべての時間を費やしている質問に答えてくれて、前もって感謝します...

4

2 に答える 2

0

私は前にこのような問題に直面しました! 実際、私のxmlに editText が含まれている場合、プレビューはまったく表示されません!! Androidスタジオに切り替えました。それはただ素晴らしいです!

于 2013-06-25T07:06:11.443 に答える