FrameLayout对孩子的保证金底部不起作用

时间:2013-03-11 12:41:23

标签: android android-layout android-view android-framelayout

我有以下视图层次结构:

<FrameLayout>
   <LinearLayout>
       <!-- Some Child views-->
   </LinearLayout>
   <ImageView>
   </ImageView>
</FrameLayout>

我尝试设置ImageView的底部边距,并且在布局编辑器上它似乎正在工作,但是当我运行代码时,底部边距我设置它被丢弃。

重要提示:我还将margin top定义为ImageView确定

我看到了其他问题并且我已经尝试gravity子视图的FrameLayout设置为top,但这也不起作用。< / p>

我还看到此问题已解决Android&gt; 3.0(我正在运行4) - Link to the issue

1 个答案:

答案 0 :(得分:1)

您始终可以将ImageView打包到FrameLayout中,并将ImageView的所需底部边距设置为包装FrameLayout的底部填充:

<FrameLayout>
   <LinearLayout>
       <!-- Some Child views-->
   </LinearLayout>
   <FrameLayout // same attributes as the ImageView but with also android:paddingBottom="xxdp">
       <ImageView // no margin set here!>
       </ImageView>
   </FrameLayout>
</FrameLayout>

如果你说这个行为是从Honeycomb开始修复的,那么你可以使用API​​依赖的布局文件夹,我的布局用于Honeycomb以及你的任何其他API级别的布局。

相关问题