【发布时间】:2016-08-18 20:45:25
【问题描述】:
我的应用程序中需要大量文本,而到目前为止,文本只是停在我的屏幕底部。它不可滚动,所以我的页面上需要一个滚动视图。现在我明白这就像将Scrollview 放在你的activity_main.xml 中一样,但这对我来说还没有成功。
文本本身放在我的strings.xml 中,即我的activity_mains 中的文本视图。
这是我MainActivity的代码:
package com.example.rodekruis;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.text.Html;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.TextView;
public class ContactActivity extends Activity {
TextView HyperLink;
Spanned Text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_contact);
}
}
这是我的 activity_main 代码:
<LinearLayout 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:orientation="vertical"
tools:context="com.example.rodekruis.Bezoek" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginBottom="20dp"
android:src="@drawable/rkz_logo"
android:layout_marginLeft="38dp" />
<ScrollView
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="244dp"
android:layout_height="276dp"
android:layout_gravity="center"
android:text="@string/title_activity_contact"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black" />
</LinearLayout>
</ScrollView>
</LinearLayout>
这就是它在图形布局中的样子。文字中途停止,我无法向下滚动。
【问题讨论】:
-
将内部
LinearLayout高度从静态更改为Match_Parent。 -
不,不是 match_parent 而是 wrap_content ...而且 TextView 应该有 wrap_content 作为高度...所以@NicolasSimon 是一个正确的答案
-
它按照您给定的固定宽度和高度显示。留给
wrap_content
标签: java android eclipse layout