开发者

Android Table Row Image dimension

开发者 https://www.devze.com 2023-04-08 11:13 出处:网络
I want to put one image on the beginning of each row in my application . The problem is, the image is too big and when I put it there, it occupies the whole screen.

I want to put one image on the beginning of each row in my application . The problem is, the image is too big and when I put it there, it occupies the whole screen.

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_wid开发者_如何学Pythonth="fill_parent"
        android:id="@+id/tableView"
        android:layout_height="fill_parent"
        android:layout_weight=".90"
        android:stretchColumns="1"
            ></TableLayout>
    </ScrollView>

This is how I add the image :

    TableLayout tableView = (TableLayout) findViewById(R.id.tableView);
    TableRow row = new TableRow(this);
    ImageView im;
    im = new ImageView(this);
    im.setImageResource(R.drawable.rss);
    row.addView(im); 
    tableView.addView(row, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,  LayoutParams.WRAP_CONTENT));

I add the rows dynamically so, I want to add the image the same way.

PS: There is no change if I replace

TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

with

TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

I would like to make the image much smaller. Could you help me out?


add the imageview this way..

im.setScaleType(ImageView.ScaleType.CENTER_CROP );
row.addView(im, new TableRow.LayoutParams(width, height));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号