滚动型的FrameLayout布局保证金的问题里面 [英] ScrollView inside FrameLayout layout margin's issue

查看:182
本文介绍了滚动型的FrameLayout布局保证金的问题里面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很奇怪的问题,一个的FrameLayout 持有滚动型。我的布局看起来如下:

I have a very weird issue with a FrameLayout holding a ScrollView. My layout looks like the following:

<FrameLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_marginTop="50dp">
      <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:orientation="vertical">
     </LinearLayout>
   </ScrollView>

   <...
   />
</FrameLayout>

这是我的问题出在:在滚动型标记 layout_marginTop 属性。它不翻过不同设备应用的方法相同。例如,在一个的Nexus S(运行ICS)它是通过在屏幕的加入一些空间正常PTED间$ P $,但对另一个(银河S2运行姜饼),它在屏幕的底部产生的空间,而不是屏幕的上方。

The issue that I have is with the: layout_marginTop attribute on the ScrollViewtag. It doesn't apply the same way accross different devices. For instance, on a Nexus S (running ICS) it is interpreted correctly by adding some space at the of the screen, but on another (Galaxy S2 running Gingerbread) it creates space at the bottom of the screen rather than the top of screen.

任何想法?

谢谢!


  • 看来这个问题是共同运行的Andr​​oid版本的所有设备低于3.0。

  • It seems that the problem is common to all devices running an Android version lower than 3.0.

感谢注意到那些无感额外的属性,看来他们在这里,因为的FrameLayout 里面用的LinearLayout <被包裹/ code>之前。

Thanks for noticing those non-sense extra attributes, it appears they were here because that FrameLayout used to be wrapped inside LinearLayout before.

推荐答案

通过使用固定它的android:paddingTop 滚动型而不是的android:layout_marginTop

Fixed it by using android:paddingTop on the ScrollViewinstead of android:layout_marginTop.

<FrameLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent">
   <ScrollView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:layout_paddingTop="50dp">
      <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:orientation="vertical">
     </LinearLayout>
   </ScrollView>

   <...
   />
</FrameLayout>

这篇关于滚动型的FrameLayout布局保证金的问题里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆