【问题标题】:create static button at the end of footer in android在android的页脚末尾创建静态按钮
【发布时间】:2012-02-28 22:25:49
【问题描述】:

我想在 ListView 的末尾创建按钮,这意味着在页脚处与视图保持一致,但是当 listview 向下滚动时,它必须在 android 的视图结束时保持静态。看看我的代码 Here

【问题讨论】:

  • 您是否尝试过在 Layout 中包含 ListView 和 Button?

标签: android


【解决方案1】:

使用相对布局来包围您的 Listview 和您的按钮。在按钮中使用属性 alignParentBottom=true...

【讨论】:

  • 我希望按钮成为视图上的静态
  • 在 Nitesh 的布局中 ... 将您的列表视图和按钮包含在相对布局中。将 listview 的 layout_height 设为 wrap_content 而不是 fill_parent。
【解决方案2】:

在使用两种布局的列表视图中,一种用于按钮,另一种用于列表视图。这是按钮保持静态的解决方案。

    <RelativeLayout 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
      >
    <Button 
     android:layout_width="wrap_content"
      android:layout_height="wrap_content"  
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true"  
      />    
    </RelativeLayout>

    <ListView
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
     </ListView>

【讨论】:

  • 我已经试过了,当我拖动列表视图时它是不可见的,当我依赖 layout_width="fill_parent" 时它没有正确显示
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-18
  • 2016-01-10
  • 1970-01-01
  • 2011-01-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多