android - ScrollView 隐藏底部线性布局

标签 android button scrollview android-linearlayout

我的 android 应用程序中有以下 XML 布局,使用 ScrollView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="fill_parent">

<TextView.../>


<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout1">
    <CheckBox ...>
        <requestFocus></requestFocus>    
    </CheckBox>
    <CheckBox ..></CheckBox>
</LinearLayout>

<ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" >
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<TextView android:text="Block Type:" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<RadioGroup android:orientation="horizontal" android:id="@+id/inputType" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <RadioButton android:id="@+id/btCall" android:paddingRight="10px" android:text="Call" android:layout_height="wrap_content" android:layout_width="wrap_content" android:checked="true"></RadioButton>
    <RadioButton android:id="@+id/btSMS" android:paddingRight="10px" android:text="SMS" android:layout_height="wrap_content" android:layout_width="wrap_content"></RadioButton>
    <RadioButton android:id="@+id/btBoth" android:paddingRight="10px" android:text="Call + SMS" android:layout_height="wrap_content" android:layout_width="wrap_content"></RadioButton>
</RadioGroup>
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/chooseContactButton" android:text="Choose from contacts..."></Button>

<TextView android:text="Name:" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:id="@+id/inputName">d</EditText>

<TextView android:text="Number:" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="phone" android:id="@+id/inputNumber"></EditText>

<TextView android:text="SMS to send:" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:text="I'm busy right now." android:inputType="textMultiLine" android:layout_width="match_parent" android:layout_height="wrap_content" android:minLines="3" android:enabled="false" android:id="@+id/inputMsg"></EditText>
</LinearLayout>
</ScrollView> 

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_gravity="bottom">
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/okButton" android:text="Save" android:width="150px" android:visibility="gone"></Button>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/updateButton" android:text="Update" android:width="150px" android:visibility="gone"></Button>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/removeButton" android:text="Remove" android:width="150px" android:visibility="gone"></Button>
    <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/cancelButton" android:text="Cancel" android:width="150px"></Button>
</LinearLayout>

</LinearLayout>

ScrollView 上方的 View 卡住良好并且 View 滚动得足够好。 问题是包含 Buttons 的 LinearLayout 被抛出了 View 。看不见。

非常感谢任何帮助。 谢谢。

最佳答案

在 ScrollView 上,尝试将 android:layout_height 更改为 "fill_parent" 添加 android:layout_weight="1"

这应该使 ScrollView 将其高度设置为您的按钮组与其上方的其他 View 之间的间隙。

此外,尽量不要将 ScrollView 的高度设置为“wrap_content”,这没有意义,因为它的全部意义在于滚动内容(在固定高度内)。

关于android - ScrollView 隐藏底部线性布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6641836/

相关文章:

java - 带有自定义 View 的 ScrollView 不会滚动 - android?

android - ActionBar 标题随 fragment 动态变化

java - 由于 onStop() 强制关闭

python - 如何在按下后更改按钮的背景颜色并恢复到之前的颜色

asp.net - 按钮单击在更新面板中不起作用

javascript - 打开(切换到)不同产品详细信息选项卡的按钮 - Magento

iphone - iphone 上 ScrollView 缩放图像?

android水平 ScrollView

android - dom 解析器错误 : PI must not start with xml

android - 如何在没有 ViewPager 的情况下在水平 ScrollView 中获得分页功能