开发者

Table row Image size problems

I want to put one image on the beginning of each row in my application . The problem is that it shrinks the image too much . I want to make it occupy 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>

This is how I add the image :

 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));

If I change the parameters from TableRow.LayoutParams(70, 30)); the image stays the same , only the row gets bigger/smaller. Also , the image could get smaller if I make those parameters small enough but that is not what I want to do . I don't need necessarily the whole picture , a cropped zoomed in one that fills that space would be nice too . This is an example image from the website . If I put the image l开发者_StackOverflow社区ike this : row.addView(im); the image gets too big , and there is no more space for the text .


May be it's helpful to you

TableLayout tableView = (TableLayout) findViewById(R.id.tableView);

TableRow row = (TableRow) inflater.inflate(R.layout.tablerow, tableView, false);

ImageView imgDis = (ImageView) row.findViewById(R.id.spinnerEntryContactPhoto);

imgDis.setPadding(5, 5, 5, 5);
imgDis.setAdjustViewBounds(true);


// set row height width
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 50);
params.topMargin = 0;
params.bottomMargin = 0;
params.leftMargin = 0;
params.rightMargin = 0;

// If you want to set margin of row
tableView.addView(row, params); 
tablerow.xml

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView android:id="@+id/spinnerEntryContactPhoto"
        android:layout_gravity="center_vertical" 
        android:layout_width="70dip" 
        android:layout_height="30dip"/>
</TableRow>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜