アプリケーションの各行の先頭に1つの画像を配置したいとします。画像は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);
画像が大きくなりすぎ、テキストのためのスペースがなくなります。
http://stackoverflow.com/questions/4811905/android-how-to-programmatically-set-width-of-imageview-inside-tablerow –