将ImageView底部对齐到RelativeLayouts顶部

时间:2014-08-26 09:59:36

标签: android android-layout uiimageview relativelayout

如何将ImageView的底部对齐到RelativeLayout的顶部?

即:

我需要这个:

╔╤╤╤╤╤╤╤╤╤╗
║         ║
║ImageView║
║         ║
╚╧╧╧╧╧╧╧╧╧╝
╔╤╤╤╤╤╤╤╤╤╗
║         ║
║  RtvLyt ║
║         ║
╚╧╧╧╧╧╧╧╧╧╝

对于这样的事情:

╔╤╤╤╤╤╤╤╤╤╗
║         ║
║ImageView║
║         ║
╠╪╪╪╪╪╪╪╪╪╣
║         ║
║  RtvLyt ║
║         ║
╚╧╧╧╧╧╧╧╧╧╝

知道我怎么能用XML做到这一点吗?

感谢。

2 个答案:

答案 0 :(得分:2)

试试这段代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip" >
    </RelativeLayout>

</LinearLayout>

答案 1 :(得分:0)

感谢@Andrew T.,答案是在ImageView上做android:layout_above="@+id/relativelayout"

相关问题