我想在我的應用程序的每一行的開頭放一個圖像。問題是它縮小了圖像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 –