android: layout_marginBottom 在 2.2 (Froyo) 中似乎无法正常工作

标签 android layout

我在相对布局中有这个 ImageView block :

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="50dip"
    android:layout_marginLeft="81dip"
    android:src="@drawable/swipehelp"
    />

这会在 Android 1.6 的正常和高密度分辨率屏幕上正确绘制图像,但是在 Android 2.2 上它似乎忽略了 layout_marginBottom 并且始终绘制图像一直对齐到底部。有没有人以前见过这种情况,如果有,您知道解决方法吗?

编辑 1:

它位于这样声明的 RelativeLayout 中:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/excusescreen"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="@drawable/woodbg">

编辑2:

这是完整的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/excusescreen"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:background="@drawable/woodbg">
   <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imlateTopBar"
    android:layout_width="fill_parent"
    android:layout_height="44dip"
    android:background="@drawable/topandbottombars"
    android:layout_alignParentTop="true"    
    >
    <ImageView
            android:id="@+id/excHomeBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dip"
            android:layout_marginTop="7dip"
            android:src="@drawable/catexcusehomebtn"
            >
    </ImageView>
    <ImageView
            android:id="@+id/excBackToCatsBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginTop="7dip"
            android:src="@drawable/backtocats"
            >
    </ImageView>
     </LinearLayout>
     <ViewFlipper
    android:id="@+id/excuses"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="50dip"
     >
     </ViewFlipper>
     <LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imlateTopBar"
    android:layout_width="fill_parent"
    android:layout_height="44dip"
    android:background="@drawable/topandbottombars"
    android:layout_alignParentBottom="true" 
    >
    <ImageView
        android:id="@+id/emailItBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dip"
        android:layout_marginTop="7dip"
        android:src="@drawable/emailit"
        >
    </ImageView>
    <TextView
        android:id="@+id/numExcusesText"
        android:layout_width="100dip"
        android:layout_height="30dip"
        android:layout_marginLeft="5dip"
        android:layout_marginTop="7dip"
        android:textColor="#66ffffff"
        android:gravity="center"
        android:textSize="18dip"
        android:textStyle="bold"
        android:text="1/13"
        >
    </TextView>
    <ImageView
        android:id="@+id/shareItBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dip"
        android:layout_marginTop="7dip"
        android:src="@drawable/shareit"
        >
    </ImageView>
     </LinearLayout>
     <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="50dip"
    android:layout_marginLeft="81dip"
    android:src="@drawable/swipehelp"
    />

 </RelativeLayout>

编辑3

alt text

最佳答案

FrameLayout 中添加一个 View,其中包含以下内容:

android:id="@+id/gap"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_alignParentBottom="true"

现在,为了修复 layout_marginBottom,使用上面的代码:

android:layout_above="@+id/gap"

关于android: layout_marginBottom 在 2.2 (Froyo) 中似乎无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4100272/

相关文章:

java - 如何在onCreate中调用onclick函数而不点击?

java - 如何在选中复选框时进行全屏 Activity

ios - Pinterest 风格布局 iOS Storyboard

java - 以编程方式居中 WebView

javascript - 如何通过拖动整个底部边框线而不是 react 中的右下角来调整div高度?

java - 我如何知道我在点击什么 Recyclerview - Firebase 删除数据

iphone - 用于 Android、iOS 和 Flash 的 WebSocket 库

java - okhttp3如何设置dns

android - 如何关闭通过膨胀布局获得的按钮的 onClick 方法中的警告框?

python - 约束 wxPython MultiSplitterWindow Pane