照片上的半透明文本框
我试图在照片上覆盖一个半透明文本框以进行描述。点击屏幕应使其向上/向下滑动。它还应该在底部包含一个评级栏。
与 Google Goggles 非常相似 http://blogote.com/wp-content/ uploads/2010/10/GoogleGoggles1.jpg
你会怎么做?这是我到目前为止所拥有的:
<FrameLayout
android:id="@+id/mainlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:foregroundGravity="bottom"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/imgview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/hello"/>
</FrameLayout>
I'm trying to overlay a semi-transparent text box over a photo for description. Tapping on the screen should make it slide up/down. It should also contain a rating bar in the bottom.
Much like in Google Goggles http://blogote.com/wp-content/uploads/2010/10/GoogleGoggles1.jpg
How would you do it? This is what I have so far:
<FrameLayout
android:id="@+id/mainlayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
android:foregroundGravity="bottom"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/imgview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/hello"/>
</FrameLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可以通过
RelativeLayout
和SlidingDrawer
小部件轻松实现。RelativeLayout
是必需的,以便您可以将抽屉附加到布局的底部并将其在照片上方打开。SlidingDrawer
小部件有 2 个必需属性:android:handle
和android:content
。对于干净的布局,您可能需要将它们作为单独的布局文件。为了简单起见,在下面的示例中,它们包含在相同的 XML 布局中。android:background
属性作为 ARGB (Alpha RGB) 值传递即可。下面使用“#BF000000”,它是黑色的,不透明度约为 75%。ImageView
和SlidingDrawer
添加事件处理程序。只是为了好玩,这里有一个完整的工作示例...
您的布局 XML:
以及您的活动 Java:
This can be easily implemented with a
RelativeLayout
and aSlidingDrawer
widget.RelativeLayout
is required so that you can attach the drawer to the bottom of the layout and have it open over the photo.SlidingDrawer
widget has 2 required properties:android:handle
andandroid:content
. For clean layouts, you'll probably want these as separate layout files. For simplicity in the below example, they're included in the same XML layout.android:background
property as a ARGB (Alpha RGB) value. Below uses "#BF000000" which is black at roughly 75% opacity.ImageView
and yourSlidingDrawer
.Just for kicks, here's a full working example...
Your layout XML:
And your activity Java:
此链接
给出了创建透明背景颜色的想法。这是
#BF000000
。This link
gives an idea about creating a transparent background color. Here it's
#BF000000
.