首页 文章

将ImageView底部对齐到RelativeLayouts顶部

提问于
浏览
0

如何将ImageView的 bottom 与RelativeLayout的顶部对齐?

即:

我需要这个:

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

对于这样的事情:

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

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

谢谢 .

2 回答

  • 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>
    
  • 0

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

相关问题