Android:LinearLayout不显示在ScrollView下方
在我正在组装的应用程序中,试图让一些按钮出现在srcollview下面时出现了一些问题 带按钮的底部线条布局根本不会出现在屏幕上,这无疑是显而易见的,但我现在很困惑。我想,通过使用RelativeLayout作为主页的父级,然后使用android:layout_below属性,我可以相当轻松地定位它们Android:LinearLayout不显示在ScrollView下方,android,xml,scrollview,android-linearlayout,Android,Xml,Scrollview,Android Linearlayout,在我正在组装的应用程序中,试图让一些按钮出现在srcollview下面时出现了一些问题 带按钮的底部线条布局根本不会出现在屏幕上,这无疑是显而易见的,但我现在很困惑。我想,通过使用RelativeLayout作为主页的父级,然后使用android:layout_below属性,我可以相当轻松地定位它们 <?xml version="1.0" encoding="utf-8"?> <!-- ViewFlipper --> <ViewFlipper
<?xml version="1.0" encoding="utf-8"?>
<!-- ViewFlipper -->
<ViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ViewFlipper01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- Page 1 (Splash) -->
<LinearLayout
android:id="@+id/splashPage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Display Splash Image"/>
</LinearLayout>
<!-- Page 2 (Main) -->
<RelativeLayout
android:id="@+id/mainPage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/mainPage"
>
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/header"
>
<TableLayout
android:id="@+id/tableHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- Dynamic TextViews Will Go In Here -->
</TableLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttonHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/scrollView"
>
<Button
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous" />
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next" />
</LinearLayout>
</RelativeLayout>
</ViewFlipper>
<!-- End of ViewFlipper -->
将
android:layout\u alignParentBottom=“true”
添加到底部LinearLayout
。可能是您的滚动视图占用了所有可用空间。请立即尝试
<?xml version="1.0" encoding="utf-8"?>
<!-- ViewFlipper -->
<ViewFlipper
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ViewFlipper01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- Page 1 (Splash) -->
<LinearLayout
android:id="@+id/splashPage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Display Splash Image"/>
</LinearLayout>
<!-- Page 2 (Main) -->
<RelativeLayout
android:id="@+id/mainPage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/mainPage"
>
<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/buttonHolder"
android:layout_below="@+id/header"
>
<TableLayout
android:id="@+id/tableHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<!-- Dynamic TextViews Will Go In Here -->
</TableLayout>
</ScrollView>
<LinearLayout
android:id="@+id/buttonHolder"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:layout_below="@+id/scrollView"
>
<Button
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Previous" />
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next" />
</LinearLayout>
</RelativeLayout>
</ViewFlipper>
<!-- End of ViewFlipper -->
添加这两行会导致崩溃?请发布崩溃消息好吗?然后尝试清理项目并重新运行它,这样会使它们出现,但在scrollview内容的顶部会有浮动。嗯……我想我应该尝试暂时删除scrollview
,只保留TableLayout
——并将scrollview
的布局参数复制到TableLayout
。这将消除滚动控件可能带来的任何异常。一旦你开始工作,你就可以把scrollview放回去了。如果它不起作用,那么你就会知道它是scrollview特有的。哦,还有一件事,虽然不会引起你的问题,但是你的第一个id为header
的线性布局可以被删除。在TextView
中使用android:layout\u centerHorizontal=“true”。好的,删除滚动视图并将表格视图设置为显示在标题下方,这是我想要的。但是我需要滚动视图,因为当填充内容时,表格视图比屏幕大。太好了!进步。现在的问题是如何使表格滚动。一些链接:和