在线性布局权重中保持imageview的宽高比?

时间:2015-01-22 13:36:49

标签: android xml

我有以下xml代码,

采用以下设计。我的问题是蓝色区域是一个imageview,我想保持它的宽高比为500 x 500.因为它的宽度越来越小的重量,...就像在图片上...让我说到450 ...但是它看起来像450x500而不是450x450 - 如何更改代码以实现这一目标?

http://s2.postimg.org/ctlsxajzd/image.jpg

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

 >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp" 
          android:weightSum="10"
       >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"


            android:background="#000000"
            android:gravity="top"

        android:layout_weight="1"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/ImageView01"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:background="@drawable/alert_logo"
                android:gravity="top"
                android:scaleType="centerInside" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:orientation="vertical"
            android:background="#000000"
            android:layout_weight="9" >


        </LinearLayout>
    </LinearLayout>

</ScrollView

&GT;

0 个答案:

没有答案