简体   繁体   English

将ImageView底部与RelativeLayouts顶部对齐

[英]Align ImageView bottom to a RelativeLayouts top

How can I align the bottom of an ImageView to the top of a RelativeLayout? 如何将ImageView的底部与RelativeLayout的顶部对齐?

ie: 即:

I need this: 我需要这个:

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

To something like this: 对于这样的事情:

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

Any idea how I can do this in XML? 知道如何在XML中做到这一点吗?

Thanks. 谢谢。

Try this code: 试试这个代码:

<?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>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM