0

就像标题所示,我有一个 ScrollView 直到我将设备从纵向切换到横向或从横向切换到纵向以触发onConfigurationChanged()我的 Activity 事件时才会滚动。

我已经在我的 Nexus S (2.3.3) 和 Emulator (4.0.3) 上尝试了 Activity,它显示了同样奇怪的行为。

我也尝试过将布局应用于 Activity 时,仍然没有运气。

我的 Activity 的 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 回答