0

向きを変更した後、テキストビューに混乱する問題があります。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent">

<TextView
        android:text="Simple"
        android:layout_width="fill_parent"
        android:layout_height="200dp"
        android:background="@drawable/my_color_drawable"
        android:id="@+id/text1"
        android:layout_gravity="center"/><\FrameLayout>

アプリを横向きモードで起動すると、メソッドのgetLineBounds(1,tmpRect) 結果は次のようになります。

  • tmpRect.top = 69

次に、電話の向きを縦向きに変更すると、結果は次のようになります。

  • tmpRect.top = 76

ただし、ランドスケープに戻した後、結果は 74 (以前は 69) に設定され、両方の結果は今後変更されません。

アプリを縦向きモードで起動した場合の結果は 76 と 74 です。

ランドスケープで開始したときに数値が異なるのはなぜなのか、本当に興味があります。助けていただければ幸いです。

情報: アクティビティが設定されましたandroid:screenOrientation="sensor"

編集: Android > 4 を使用している場合にのみ問題が発生するようです。

ありがとう。

4

1 に答える 1

0

横向きと縦向きを使用している場合は、2 つのレイアウトが必要です。そうしないと、値が変わります。レイアウトを作成する方向に基づいてデフォルト値に設定されます。に設定された 1 つのモードでのみ作業する必要がある場合

android:screenOrientation="portrait"

また

android:screenOrientation="landscape"
于 2013-08-28T14:40:29.177 に答える