Conflict with Android ImageView

I create ImageViewin code:

ImageView vlogo = new ImageView(v.getContext());
        RelativeLayout.LayoutParams vlogoParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT);
        vlogoParams.addRule(RelativeLayout.ALIGN_TOP,tv_visitor.getId());
        vlogoParams.addRule(RelativeLayout.ALIGN_LEFT, tv_visitor.getId());
        vlogoParams.addRule(RelativeLayout.ALIGN_BOTTOM, tv_visitor.getId());
        vlogo.setLayoutParams(vlogoParams);
        vlogo.setImageResource(R.drawable.star);
        rl.addView(vlogo);

The image is scaled up by aligning it TOPand BOTTOMthe created representation tv_visitor (which was added to the relative arrangement). But I believe that this is not a gasket (?) Yet .. requestLayout before this code does not change anything.  Picture

By doing this, I set the height of the ImageView to the height of the tv_visitor view. This is normal. However, the width seems original.

And here is the problem. Width does not scale. The way I do this is doing .setAdjustViewBounds (true); does not work. How can I continue?

As stated in the comments, I provide additional information:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/news_scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ff000000"
    android:scrollbars="none">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/fragment_news2">
    <View
        android:id="@+id/anchor_n"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="#ffbb00"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true" />
</RelativeLayout>
</ScrollView>

The view is passed as a parameter, and the layout receives:

RelativeLayout rl = (RelativeLayout) v.findViewById(R.id.fragment_news2);
+4
1

Imageview, imageview ImageView.ScaleType.FIT_CENTER. FIT_CENTER :

, src, , src dst. (X Y) . dst.

, , . , ScaleType ImageView.ScaleType.FIT_END, , , , .

vlogo.setScaleType(ImageView.ScaleType.FIT_END);
+2

All Articles