0
我正在嘗試製作移動學習應用程序,並且在此應用程序中我有一個女巫用戶閱讀文本的活動。在我將活動捲動之後,我偶然發現了一個無厘頭的基本問題......我如何將文本添加到活動中? 我不知道我是否需要使用TextView,如果是,那麼我該如何修改它以顯示我需要的所有文本。 我會把下面的所有代碼:如何在Android活動中添加大量文本?
-activity的java:
public class displayCursI extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_curs_i);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
}
- 活動的xml:
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.andrei.licenta_3.displayCursI"
tools:showIn="@layout/activity_display_curs_i">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="132dp"
android:layout_marginTop="105dp"
android:text="@string/text"
android:textAlignment="center" />
</ScrollView>
- 串XML
<string name="app_name">Licenta_3</string>
<string name="action_settings">Settings</string>
<string name="button_cursuri">Cursuri</string>
<string name="button_chestionar">Chestionar</string>
<string name="title_activity_display_cursuri">displayCursuri</string>
<string name="button_I">I</string>
<string name="button_II">II</string>
<string name="button_III">III</string>
我明白你的意思,但我需要添加整頁的文本書籍文本,我想知道如果我可以在「文本框」這種方式,我可以複製文本frome媽媽和粘貼它在 –
你也可以嘗試這一點,我會說你不能用'wrap_content'替換textView的'height'和'width',嵌套在滾動視圖中。 –
你發貼給我一個例子嗎?因爲我是新來的,不想搞砸 –