比如我有一张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>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="?"
android:scaleType="fitXY"
android:src="@drawable/testimage">
</ImageView>
解决方案 »
- 内存不足10000-byte external allocation too large for this process
- android有哪些可以用的chart开发包?
- 有关Android绘图的两个问题
- android xmlns:android
- 怎么使用 com.android.* 下的包
- 安卓api,关于获取屏幕分辨率的问题
- 关于使用service的上下文和activity来读取sharedpreferences的同步问题
- 全局Application
- 请问, msg.sendToTarget(); 往什么地方发?
- 安卓APP里switch开个默认是开启的 功能也是开启的
- popupwindow改变背景颜色已经透明度的问题
- android网络数据流量监控
可能对你有帮助
android:scaleType="fitXY"
改为
android:scaleType="fitCenter"
试试?
android:scaleType="matrix"
* 初始化组件的大小
*/
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);
}以前处理图片写的方法 可以参考下