所以,我有ScrollView一个孩子 - 一个LinearLayout有两个孩子:a TextView和a ViewPager.ViewPager包含许多元素的布局,这就是为什么我需要垂直滚动的能力.只有页面ViewPager可以水平滚动(即:我只想在其中水平滑动ViewPager).那一个TextView不能水平滚动,但应该与我一起滚动ViewPager.
简单?没有.
我在StackOverflow中看到了非常类似的问题(这里,这里,这里和这里).所有建议的解决方案都不适合我:(
我看到的是这个 < - 我的甜蜜UI :),但我无法垂直滚动:(
在ViewPager中嵌入ScrollViews不是一个选项 - UI的设计禁止这样做.
也许这是我用编程方式填充视图寻呼机中的每个页面的东西?嗯...
任何建议,将不胜感激.
我的代码:
activity_main.xml中:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/linearLayoutGeneral"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tvText"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:text="Test text" />
<android.support.v4.view.ViewPager
android:id="@+android:id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</android.support.v4.view.ViewPager>
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
ViewPager中的每个页面都有这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) android android-fragments android-scrollview android-viewpager
我有一个FragmentActivity来设置tabhost.每个选项卡都是一个名为TabFragment的简单片段.TabFragment有一个ViewPager,在这种情况下它是antonyt的InfiniteViewPager (在这里讨论:ViewPager作为循环队列/包装).
(主要)问题如下:
我启动了应用程序.我点击第二个标签.当我看到与第一个标签中相同的内容时,只有一个空白屏幕.向右滚动几次后,我看到了我的TextViews.
在ViewPagers中滚动片段并更改选项卡最终会导致停止和FC,并且不会抛出任何明确的异常.
这是我对Fragments的第一次采取,我必须承认,我不理解观察到的行为.
任何提示将不胜感激.
整个项目都在这里.
代码:
使用TabHost的FragmentActivity:
package com.example.viewpagerintab;
import java.util.HashMap;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabContentFactory;
public class TabsFragmentActivity extends FragmentActivity implements
TabHost.OnTabChangeListener {
private TabHost mTabHost;
private HashMap mapTabInfo = new HashMap();
private TabInfo mLastTab = null;
public TabsFragmentActivity() {
}
private class TabInfo {
private String tag;
private Class clss;
private Bundle args;
private Fragment fragment;
TabInfo(String tag, …Run Code Online (Sandbox Code Playgroud) android android-fragments android-viewpager android-tabs android-nested-fragment