Android 相对于其他布局的ImageView大小
我正在为当前应用程序中的抽屉创建标题。问题是我想给它添加一个背景图像,所以我创建了一个RelativeLayout,并首先插入一个ImageView,然后插入另一个布局 我没有给布局添加背景,因为它破坏了一切 我的问题是,我想放的图像很长,并且没有很大的高度。。。我希望图像高度适合其他布局的高度,并相应地适合宽度 以下是我的xml:Android 相对于其他布局的ImageView大小,android,image,layout,Android,Image,Layout,我正在为当前应用程序中的抽屉创建标题。问题是我想给它添加一个背景图像,所以我创建了一个RelativeLayout,并首先插入一个ImageView,然后插入另一个布局 我没有给布局添加背景,因为它破坏了一切 我的问题是,我想放的图像很长,并且没有很大的高度。。。我希望图像高度适合其他布局的高度,并相应地适合宽度 以下是我的xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="htt
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/draw_header"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:src="@drawable/drawer_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
<LinearLayout
android:id="@+id/layout_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/header_layout_texts"
android:paddingTop="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="0.15">
<TextView
android:id="@+id/header_text_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="16sp"
android:text="@string/navigation_drawer_message_require_login"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:freezesText="true"/>
<TextView
android:id="@+id/header_text_club"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white_translucent"
android:paddingRight="10dp"
android:paddingLeft="15dp"
android:freezesText="true"/>
<TextView
android:id="@+id/header_text_handicap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="16sp"
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:freezesText="true"/>
</LinearLayout>
<ImageView
android:id="@+id/header_image_logo"
android:src="@drawable/logo_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/header_layout_texts"
android:adjustViewBounds="true"
android:layout_weight="0.2"/>
</LinearLayout>
</RelativeLayout>
谢谢 无法正确理解我希望ImageView
drawer\u标头
与LinearLayout
layout\u标头的高度相同,将这两个布局放在另一个RelativeLayout中,并将RelativeLayout的高度定义为某个常量,然后将匹配父项应用于布局的高度。