0

I'm passing the URI of the resource I want to use to the activity that's supposed to display it with a description. Here's the code:

        public void onClick(View v) {
            final String root = "android.resource://" + getPackageName() + "/";
            Intent myIntent = new Intent( v.getContext(), SingleMoveView.class);
            myIntent.setData(Uri.parse(root + R.drawable.simby));
            myIntent.putExtra("Desc", getResources().getString(R.string.simbus));
            startActivity(myIntent);
        }

and in the SingleMoveView class:

    ImageView view = (ImageView) findViewById(R.id.singleMoveView);
    TextView text = (TextView) findViewById(R.id.singleMoveDesc);

    Uri path = getIntent().getData();
    String desc = getIntent().getStringExtra("Desc");

    view.setImageURI(path);
    text.setText(desc);

What's happening is I've set up the ImageView and TextView in the XML as such:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:theme="@android:style/Theme.Holo.NoActionBar">

    <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/singleMoveView"
            android:layout_margin="20dp"/>

    <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:id="@+id/singleMoveDesc"
            android:layout_margin="20dp"
            android:layout_below="@+id/singleMoveView"
            android:layout_alignParentLeft="true"/>
</RelativeLayout>

But it's displaying the image in the absolute center of the screen: What it is doing

Instead of on top w/text underneath. [Note the picture isn't displayed. view.setImageURI(path); was commented out]

What it should be doing

Help please? How do I get it to display properly. Thanks! ^_^

4

1 回答 1

0

问题解决了。这是图片尺寸的问题。我不得不调整它的大小...

于 2013-09-29T05:15:50.967 回答