在标签布局内的Android可滚动视图
我目前有一个在android布局的标签内的可滚动视图的问题。如下所示,该视图在选项卡布局中没有实现可滚动视图的情况下滚动浏览。在标签布局内的Android可滚动视图
http://i46.tinypic.com/2ccmp0w.png
当我把选项卡式布局内可滚动视图它显示了出现车和不可用的一个小的可滚动视图。如下所示。
http://tinypic.com/r/29ej2ft/6
用于选项卡主机的代码是下面
<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:padding="5dp" />
<TabWidget
android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
</TabHost>
并且这是用于与滚动视图的选项卡中的代码来实现
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/todayScroll"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<ExpandableListView
android:id="@+id/ExpList"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:groupIndicator="@null" />
</LinearLayout>
</ScrollView>
如何任何想法得到的内容滚动正确,而不是在选项卡的方式将不胜感激:)谢谢。
我已经尝试了公平的几次,但它开始变得非常沮丧。编辑: 这里是TabHostActivity文件。
public class TabbedMainActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_main);
TabHost tabHost = getTabHost();
// Tab for todays meals
TabSpec todaysSpec = tabHost.newTabSpec("Todays");
//you could set icon here as well as title
todaysSpec.setIndicator("Todays");
Intent todaysIntent = new Intent(this, TodaysMealsActivity.class);
todaysSpec.setContent(todaysIntent);
// Tab for future meals
TabSpec futureSpec = tabHost.newTabSpec("Future");
futureSpec.setIndicator("Future");
Intent futureIntent = new Intent(this, FutureMealsActivity.class);
futureSpec.setContent(futureIntent);
// Tab for comments
TabSpec commentsSpec = tabHost.newTabSpec("Comments");
commentsSpec.setIndicator("Feedback");
Intent commentsIntent = new Intent(this, CommentsActivity.class);
commentsSpec.setContent(commentsIntent);
// Adding all TabSpec to TabHost
tabHost.addTab(todaysSpec); // Adding todays tab
tabHost.addTab(futureSpec); // Adding future tab
tabHost.addTab(commentsSpec); // Adding comments tab
}
}
干杯, Rmplanner
从评论编辑:另一种解决方案(一个由OP使用)被发现here。
在您的ScrollView
上使用android:layout_height="fill_parent"
。 (或者,因为fill_parent
已过时,使用android:layout_height="match_parent"
。)
首先,删除您ScrollView
,以及与此更换你的RelativeLayout
:
<RelativeLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_above="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
<TabWidget
android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
嗨,感谢您的快速回复,但不幸的是,这并没有解决这个问题。滚动视图仍然很小,无法填充和匹配父项。 – rmplanner 2012-08-01 02:02:48
你可以编辑你的OP,以显示你如何在你的标签中包含'ScrollView'?看起来有可能的是,包含ScrollView的任何东西都使用'wrap_content'。 – Eric 2012-08-01 02:04:18
因为我对android非常陌生,所以我不确定你的问题,但是我可以从你的问题中收集的是你要求标签主机的活动。如果是这样 - 我现在编辑它;如果不是,请澄清,如果你想要更多的信息。 – rmplanner 2012-08-01 02:14:50
为什么你保持一个ListView滚动型内的LinearLayout内。为什么不能使用listview或listactivity? – san 2012-08-01 03:25:04