自动图像缩放到Android布局内屏幕宽度的百分比

自动图像缩放到Android布局内屏幕宽度的百分比,android,android-layout,Android,Android Layout,我想复制下面的布局 但我不能正确地重现红色矩形内的区域。迄今为止的代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="match_parent"

我想复制下面的布局

但我不能正确地重现红色矩形内的区域。迄今为止的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="centerCrop"
    android:src="@drawable/graph_bg" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:orientation="horizontal">
    <View
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.13">
    </View>

    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginTop="32dp"
        android:layout_marginBottom="32dp"
        android:layout_marginRight="8dp"
        android:orientation="vertical"
        android:background="@color/white"
        android:gravity="center"
        android:layout_weight="0.74">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="centerInside"
            android:src="@drawable/pic_mw_logo" />
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/calcs"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#000000" />
    </LinearLayout>
    <View
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="0.13">
    </View>

</LinearLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">
    <TextView
        android:id="@+id/sponsored_descr"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="Sponsored by\nxxxx"/>
<!--- LOGOS HERE I SUPPOSE -->        

</RelativeLayout>

</RelativeLayout>


底部的两个徽标都是尺寸约为200x100像素的图片。我希望将它们缩放到屏幕宽度的15%左右,并像图片上那样显示

您可以始终使用
LinearLayout
并设置空的
视图
组件,并为它们赋予
布局权重
属性


如果需要15%的屏幕大小,请将
线性布局的宽度设置为
match\u parent
,将
weightSum
设置为
100
,并为图像赋予
权重
15
。请务必设置空白<代码>视图> />代码>您必须完成权重100。

您可以始终使用<代码>线性布局< /C> >并设置空<代码>视图< /C>组件,并给它们<代码> LayOutoSuth属性>


如果需要15%的屏幕大小,请将
线性布局的宽度设置为
match\u parent
,将
weightSum
设置为
100
,并为图像赋予
权重
15
。请务必设置空白<代码>视图>代码> s。您必须将权重完成到100。

尝试使用简单的<代码> RealValayOut< <代码>,只需添加<>代码> App:LayOutHealth% 属性,并使用所需的百分比。由于它是支持库的一部分,您应该将
compile'com.android.support:percent:23.0.1'
添加到您的gradle依赖项中。

尝试使用而不是简单的
RelativeLayout
,只需添加
app:layout\u heightPercent
属性和您想要的百分比。由于它是支持库的一部分,您应该在gradle依赖项中添加
compile'com.android.support:percent:23.0.1'

简单地将“赞助商”和徽标设置为单个图像可能是个好主意,但我希望可以在xml中完成。简单地将“赞助商”和徽标设置为单个图像可能是个好主意,但我希望它可以在xml内部完成。