Reputation:
I need a lot of text in my app, and so far, the text just stops at the bottom of my screen. It's not scrollable, so I need a scrollview on my page. Now I understood that it's just something like putting Scrollview
in your activity_main.xml
, but that hasn't worked out for me yet.
The text itself is put in my strings.xml
, the textviews in my activity_mains.
This is the code for my 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);
}
}
This is my activity_main code:
<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>
This is how it looks like in the Graphic Layout. The text stops halfway, i'm not able to scroll down.
Upvotes: 0
Views: 56
Reputation: 13535
try something like this... you constraint the size at the scrollview instead of the textview.
<ScrollView
android:id="@+id/scrollview"
android:layout_width="244dp"
android:layout_height="276dp"
>
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="@string/title_activity_contact"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black" />
</ScrollView>
Upvotes: 0
Reputation: 5287
Simply change your layout as follow :
<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">
<TextView
android:id="@+id/textView1"
android:layout_width="244dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/title_activity_contact"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/black" />
</ScrollView>
</LinearLayout>
Upvotes: 1
Reputation: 12953
Try changing the height of the scrollview
to wrap_content
like this:
<ScrollView
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
Upvotes: 0