我将一个Scrollview放在tabLayout上的一个标签内。在scrollview中有一个textview,但是当我尝试向下滚动时,页面缩短了,我无法看到所有的scrollview。我该如何解决这个问题?
这是我的滚动视图的XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end">
<TextView
android:padding="@dimen/welcome_text_padding"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="@dimen/welcome_text_size"
android:id="@+id/intro_text"/>
</ScrollView>
</LinearLayout>
我知道这里的LinearLayout是多余的,但这不是问题吗?
这是片段类
package com.example.lucas.guide;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class WelcomeMOBA extends Fragment{
public WelcomeMOBA() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View myInflatedView = inflater.inflate(R.layout.fragment_welcome_moba, container,false);
final TextView introText = (TextView) myInflatedView.findViewById(R.id.intro_text);
introText.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "HelveticaNeueLight.otf"));
introText.setText("this is text and it exceeds the screenspace");
return myInflatedView;
}
}
此外,这是包含上述片段的类的XML。
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />