【问题标题】:Android - right side screen buttonAndroid - 右侧屏幕按钮
【发布时间】:2014-10-08 14:02:12
【问题描述】:

我想问你是否可以将按钮放置在另一个视图的“上方”。我想要实现的是一个带有 ListView 和一个圆形按钮的活动,它是从屏幕右侧“来”的。但是,如果有人向下滚动,按钮必须停留在它的位置,一旦按下,就会调用新的片段。事实上,我一开始就被卡住了,不知道该怎么做,所以欢迎每一个建议/提示/建议。

PS: Button 应该是用来添加新项目到 ListView 中的

另外,我已经创建了一个草图以便更好地解释。

谢谢, 问候

【问题讨论】:

  • 你可以使用 FrameLayout。
  • 尝试将这些元素放在RelativeLayout中并设置按钮的属性 android:align_ParentRight="true" 和 android:center_vertically="true"
  • 感谢你们这么快的反应,但是如果我向下滚动,按钮也不会随着“项目”一起向下移动?
  • 自己尝试会更快,但不,它不会随列表视图一起移动,因为它不是列表视图的一部分,而是其父视图的一部分。您应该阅读一些基本的 android 布局教程...
  • 感谢@ElDuderino 的回答!欣赏

标签: android user-interface android-listview android-button android-scrollview


【解决方案1】:

我试过了,效果很好。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >

<ListView
    android:id="@+id/listAlertItems"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:dividerHeight="1px"
    android:listSelector="@android:color/transparent" />

<ImageView
    android:id="@+id/clickBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerInParent="true"
    android:src="@drawable/ic_img" />

这是结果:

【讨论】:

  • 非常感谢@Farouk Touzi :)
  • 也感谢 Juan Aguilar Guisado :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-17
  • 1970-01-01
  • 2021-11-22
  • 1970-01-01
  • 2019-05-06
  • 2019-01-20
相关资源
最近更新 更多