gpt4 book ai didi

android - 如何修复 scrollview android 底部的按钮?

转载 作者:行者123 更新时间:2023-12-05 00:09:51 27 4
gpt4 key购买 nike

我有以下布局。

我有一个位于屏幕底部的按钮。

我已将我的表格布局放在 ScrollView 中,它可以完美滚动。

但是使用 ScrollView 会使底部按钮消失。我该如何修复它。

这是我的xml布局文件

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="80dp"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="61dp"
android:gravity="center"
android:text="Interest Rates on Domestic Term Deposits (w.e.f. 26th Septemr, 2013)"
android:textColor="@color/White" />

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/Red"
android:gravity="center" >

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Pariculars"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="General"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Senior Citizens(p.a.)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Revised for deposit upto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Revised for deposit upto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Revised for deposit upto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Rs. 15 Lacs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Rs. 15 Lacs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Rs. 15 Lacs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7days to 14 days"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.25%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.25%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="15 days to 90 days"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.75%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.75%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="91 days to 180 days"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="8.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="8.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="181 days to 12 months"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="9.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="9.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom" >

<Button
android:id="@+id/homeInterestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Home" />
</RelativeLayout>

我只需要我的表格布局内容可以滚动,并且主页按钮应该位于 Activity 的底部。

最佳答案

为您的 ScrollView 添加 android:fillViewport="true" 属性。请参阅下面的代码。

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:fillViewport="true"
android:layout_weight="1" >

还更改如下代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="80dp"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="61dp"
android:gravity="center"
android:text="Interest Rates on Domestic Term Deposits (w.e.f. 26th Septemr, 2013)"
android:textColor="@color/White" />

<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/Red"
android:gravity="center" >

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Pariculars"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="General"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Senior Citizens(p.a.)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Revised for deposit upto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Revised for deposit upto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Revised for deposit upto"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Rs. 15 Lacs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Rs. 15 Lacs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Rs. 15 Lacs"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7days to 14 days"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.25%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.25%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="15 days to 90 days"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.75%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="7.75%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="91 days to 180 days"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="8.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="8.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>

<TableRow
android:id="@+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >

<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="181 days to 12 months"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="9.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />

<TextView
android:id="@+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="9.50%"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/White" />
</TableRow>
</TableLayout>
</ScrollView>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom" >

<Button
android:id="@+id/homeInterestButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Home" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>

关于android - 如何修复 scrollview android 底部的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21474102/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com