比如我有一张4:3的图片,我设置了android:layout_width="fill_parent",那么android:layout_height改怎么设置才能实现等比缩放。
<ImageView 
android:id="@+id/ImageView01" 
android:layout_width="fill_parent" 
android:layout_height="?" 
android:scaleType="fitXY"
android:src="@drawable/testimage">
</ImageView>

解决方案 »

  1.   

    http://dev.10086.cn/cmdn/wiki/index.php?doc-view-4914.html
    可能对你有帮助
      

  2.   


    android:scaleType="fitXY"
    改为
    android:scaleType="fitCenter"
    试试?
      

  3.   

    android:layout_height="wrap_content"
    android:scaleType="matrix"
      

  4.   

        /**
         * 初始化组件的大小
         */
        private void getPicSize() {
         Display display = getWindowManager().getDefaultDisplay();
         double screenHeight = display.getHeight();
         double screenS = 0.3; //基本信息和详细信息的比例
         double picS = 1.4; //照片的宽高比
        
         int baseLayoutHeight = (int) (screenHeight * screenS);
        
         //设置基本信息的高度
         LayoutParams mParams = baseInfoLayout.getLayoutParams();
         mParams.height = baseLayoutHeight;
         mParams.width = LayoutParams.FILL_PARENT;
         baseInfoLayout.setLayoutParams(mParams);
        
         int imgWidth = (int)(baseLayoutHeight / picS);
        
         //设置图片的比例
         LayoutParams imgParams = imgView.getLayoutParams();
         imgParams.height = LayoutParams.FILL_PARENT;
         imgParams.width = imgWidth;
         imgView.setLayoutParams(imgParams);
        }以前处理图片写的方法 可以参考下