Android:使用FrameLayout将buttonalignment到屏幕的右下angular?

我正试图把地图的缩放控制放在屏幕的右下angular。 我可以用RelativeLayout同时使用alignParentBottom="true"alignParentRight="true" ,但与Framelayout我没有find任何这样的属性。 我如何将它与屏幕的右下angularalignment?

其实这是可能的,尽pipe在其他答案中说了什么。 如果你有一个FrameLayout ,并且想把一个子项目放在最下面,你可以使用android:layout_gravity="bottom" ,这个子对象将会和FrameLayout的底部alignment。

我知道这是有用的,因为我正在使用它。 我知道已经很晚了,但是在google上排名靠前的其他人可能会很方便

我也遇到这种情况,并找出如何使用FrameLayout。 以下输出由以下代码生成。

一些右下角对齐的文本使用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> 

更改边距值以调整图像上的文字位置。 删除保证金可能会使文本有时不在视图中。

可以使用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> 

设置android:layout_gravity="bottom|right"为我工作

两种方法来做到这一点:

1)使用框架布局

 android:layout_gravity="bottom|right" 

2)使用相对布局

 android:layout_alignParentRight="true" android:layout_alignParentBottom="true" 

机器人:layout_gravity = “底部”

你可以添加一个不可见的TextView到FrameLayout。

  <TextView android:layout_width="wrap_content" android:layout_height="0dp" android:layout_weight="1" android:visibility="invisible" /> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:orientation="horizontal"> <Button android:id="@+id/daily_delete_btn" android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="1" android:text="DELETE" android:layout_gravity="center"/> <Button android:id="@+id/daily_save_btn" android:layout_width="0dp" android:layout_height="50dp" android:layout_weight="1" android:text="SAVE" android:layout_gravity="center"/> </LinearLayout> 

如果你想用java代码尝试。 干得好 –

  final LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); yourView.setLayoutParams(params); params.gravity = Gravity.BOTTOM; // set gravity 

你不能用FrameLayout来做。

从规格:

http://developer.android.com/reference/android/widget/FrameLayout.html

“FrameLayout被devise为阻挡屏幕上的一个区域显示一个项目,你可以添加多个子项到一个FrameLayout,但是所有的子项都被固定在屏幕的左上angular。

为什么不使用RelativeLayout?