Android 滚动条是否自动在应用程序中生成?
我正在写一个应用程序,它在最后显示文本——实际上是很多文本,因为甚至40行甚至更多。问题是,在emulator中,我无法向下滚动屏幕以查看整个文本 我的问题是: 我是否必须打开滚动条,或者任何允许用户向下滚动并查看所有结果的功能 或者它是自动添加的,比如网页上的滚动条,默认在哪里 编辑: xml是这样的:Android 滚动条是否自动在应用程序中生成?,android,text,scrollbar,Android,Text,Scrollbar,我正在写一个应用程序,它在最后显示文本——实际上是很多文本,因为甚至40行甚至更多。问题是,在emulator中,我无法向下滚动屏幕以查看整个文本 我的问题是: 我是否必须打开滚动条,或者任何允许用户向下滚动并查看所有结果的功能 或者它是自动添加的,比如网页上的滚动条,默认在哪里 编辑: xml是这样的: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="ht
<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: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=".MainActivity4" >
<TextView
android:id="@+id/text_promil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/text_e"
android:layout_alignBottom="@+id/text_e"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:text="promil" />
<TextView
android:id="@+id/text_e"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="41dp"
android:text="e" />
<TextView
android:id="@+id/text_alkomat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/text_promil"
android:text="Spadek stezenia alkoholu w Twojej krwi:" />
</RelativeLayout>
上次编辑:
对不起,应该知道这两行必须剪切粘贴到滚动视图,然后一切正常。我不熟悉XML,它是通过图形创建创建的,所以我真的不知道写了什么。然而,一切都很顺利,这要感谢你们 您必须在布局中使用
ScrollView
作为父级。并将您的文本视图
或任何布局作为此滚动视图
例如
<ScrollView>
<TextView />
<ScrollView>
有关详细信息,它不是自动生成的,您需要将其添加到xml中。您的
ScrollView
只需要有一个孩子。如果要在滚动视图上添加多个文本视图,请在滚动视图
中添加相对或线性布局,然后在此布局中添加多个文本视图
。用一个文本视图查看以下代码:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text"
/>
</ScrollView>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text"
/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text 2"
/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text 3"
/>
</RelativeLayout>
</ScrollView>
你们能看看我刚刚发布的xml布局吗?我知道你们已经发现了那个些xml错误。如果我的答案对您有帮助,请将其标记为答案:)
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text"
/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text 2"
/>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text 3"
/>
</RelativeLayout>
</ScrollView>