【发布时间】:2011-09-30 10:05:51
【问题描述】:
我想在我的应用程序的每一行的开头放置一个图像。问题是它缩小了图像 too much 。我想让它占据the whole space。
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="vertical"
>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/tableView"
android:layout_height="fill_parent"
android:layout_weight=".90"
android:stretchColumns="1"
></TableLayout>
</ScrollView>
这就是我添加图像的方式:
TableLayout tableView = (TableLayout) findViewById(R.id.tableView);
TableRow row = new TableRow(this);
ImageView im;
Bitmap bmp;
im = new ImageView(this);
bmp=getbmp(s);
im.setImageBitmap(bmp);
row.addView(im, new TableRow.LayoutParams(70, 30));
tableView.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
如果我从TableRow.LayoutParams(70, 30)); 更改参数,图像保持不变,只有行变大/变小。此外,如果我使这些参数足够小,图像可能会变小,但这不是我想要做的。我 不一定 需要 整个 图片 , 一个 裁剪 的 放大 的 填充 那个 空间 也 很好 . This 是来自网站的示例图片。如果我这样放图片:row.addView(im); 图片太大了,文字就没有空间了。
【问题讨论】:
标签: android image view scale image-size