0
這裏是我的一個Android應用XML:的TextView不滾動水平模式
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="5"
android:background="@drawable/gradient"
android:gravity="fill_horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".PNRActivity" >
<EditText
android:id="@+id/pnr_num"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:gravity="top|center"
android:hint="@string/pnr_number"
android:inputType="number"
android:maxLength="10" >
<requestFocus />
</EditText>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="45dip" >
<Button
android:id="@+id/btnStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btn_pnr"
android:text="@string/btnGetStatus" />
<TextView
android:id="@+id/centerPoint"
android:layout_width="5dip"
android:layout_height="wrap_content"
android:paddingTop="15dip"
android:text="" />
<Button
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/btn_pnr"
android:text="@string/btnClear" />
</LinearLayout>
<TextView
android:id="@+id/txtOutput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/linearLayout1"
android:layout_alignRight="@+id/linearLayout1"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:maxLines = "10"
android:text="@string/txtOut"
android:scrollbars = "vertical"
android:freezesText="true"
android:background="@drawable/border"
android:padding="10dip" />
</RelativeLayout>
我想要的TextView與ID爲txtOutput滾動。我做到這一點:
textView.setMovementMethod(new ScrollingMovementMethod());
然而在水平方向滾動不起作用! 另外我使用freezesText使文本以水平佈局顯示。但水平滾動仍然不起作用。 我該如何使它工作?
如何處理這樣的標籤? android:layout_alignLeft =「@ + id/linearLayout1」 –
很好。別管它吧。 – yams
顯示警告,因爲最後一個TextView txtOutput未包含在線性佈局中! –