0

onConfigurationChanged()タイトルが示すように、アクティビティのイベントをトリガーするためにデバイスを縦向きから横向きに、または横向きから縦向きに切り替えるまでスクロールしないScrollViewがあります。

Nexus S(2.3.3)とエミュレーター(4.0.3)でアクティビティを試しましたが、同じ奇妙な動作が表示されます。

レイアウトがアクティビティに適用されるときにも試してみましたが、まだ運がありません。

アクティビティのXMLレイアウトはここにあります(少し長いので、質問をXMLで乱雑にしたくありませんでした)。

これが私を助けるためにあなたたちが見るのに関連するかもしれないいくつかのコードです:

/** {@inheritDoc} */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.terms_and_agreements);

    //fire up the AsyncTask to get data
    showLoadingProgress();
    mBookingInfoTask = new BookingInfoTask();
    mBookingInfoTask.execute();
}

/** {@inheritDoc} */
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

/** This methode is called when the BookingInfoTask has finished collecting date from the server */
public void onBookingInfoResult(String clubTerms, String portalTerms) {
    final String fClubTerms = clubTerms;
    final String fPortalTerms = portalTerms;
    runOnUiThread(new Runnable() {
        public void run() {
            TextView tvTerms = (TextView) findViewById(R.id.tvTerms);
            tvTerms.setText(fClubTerms + "\n\n" + fPortalTerms);
        }
    });

    hideProgress(); //Hides progress bar
}

そして最後に、これが私のアクティビティのマニフェスト宣言です:

    <activity
        android:name=".ConfirmationActivity"
        android:configChanges="keyboardHidden|orientation"
        android:theme="@android:style/Theme.NoTitleBar" />
4

1 に答える 1

1

TextView(親を埋めるはずだった)を次のような線形レイアウトでラップすることで機能するようになりました。

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >

        <TextView
            android:id="@+id/tvTerms"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1.0"
            android:paddingBottom="6dip"
            android:paddingLeft="6dip"
            android:paddingRight="6dip"
            android:textColor="#000000" />
    </LinearLayout>

スクロールできなかったときの様子は次のとおりです。

<TextView
    android:id="@+id/tvTerms"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1.0"
    android:paddingBottom="6dip"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
    android:textColor="#000000" />

そして今、それは本来あるべきようにスクロールしています!

于 2012-02-03T16:37:56.620 に答える