首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >安卓:使用FrameLayout将按钮对齐到屏幕右下角?

安卓:使用FrameLayout将按钮对齐到屏幕右下角?
EN

Stack Overflow用户
提问于 2010-11-08 20:02:56
回答 10查看 162.8K关注 0票数 120

我正在尝试将地图的缩放控件放在屏幕的右下角。我可以使用alignParentBottom="true"alignParentRight="true"在RelativeLayout中做到这一点,但是在Framelayout中我找不到任何这样的属性。如何将其与屏幕右下角对齐?

EN

回答 10

Stack Overflow用户

回答已采纳

发布于 2011-05-06 18:26:11

实际上,这是可能的,尽管在其他答案中是这样说的。如果您有一个FrameLayout,并且想要将一个子项放置在底部,您可以使用android:layout_gravity="bottom",这将使该子项与FrameLayout的底部对齐。

我知道它是有效的,因为我正在使用它。我知道为时已晚,但这对其他人来说可能会很方便,因为这在谷歌上排名靠前

票数 269
EN

Stack Overflow用户

发布于 2012-09-22 16:56:16

我也遇到了这种情况,并想出了如何使用FrameLayout来做到这一点。以下输出由下面给出的代码生成。

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

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/contactbook_icon"
                        android:layout_gravity="center" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="140"
                        android:textSize="12dp"
                        android:textColor="#FFFFFF"
                        android:layout_gravity="bottom|right"
                        android:layout_margin="15dp" />
                </FrameLayout>

更改边距值以调整图像上的文本位置。删除页边距有时可能会使文本从视图中消失。

票数 58
EN

Stack Overflow用户

发布于 2011-01-16 20:51:36

它可以使用RelativeLayout来实现

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

   <ImageView 
      android:src="@drawable/icon"
      android:layout_height="wrap_content"
      android:layout_width="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentBottom="true" />

</RelativeLayout>
票数 38
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4123630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档