虽然scaletype设置为fitcenter,但FrameLayout中的图像没有缩小

时间:2014-10-08 18:54:52

标签: android android-framelayout scaletype

我有ImageView必须包含在Framelayout内。但是当我使用FrameLayout时,即使我使用ImageView ViewGroup setScaleType(ScaleType.FitCenter); but when I use other RelativeLayout`,图像也会被限制在such as的范围内并且不会“适合”,结果没关系。为什么?我能做什么?这是我的代码:

    FrameLayout profileimage_fl = new FrameLayout(
            getSherlockActivity());
    layoutWidth = WindowSize.convertedHeight(150);
    layoutHeight = WindowSize.convertedHeight(150);
    p_ll = new LinearLayout.LayoutParams(layoutWidth, layoutHeight);
    leftMargin = WindowSize.convertedWidth(1);
    topMargin = WindowSize.convertedHeight(1);
    rightMargin = WindowSize.convertedWidth(1);
    bottomMargin = WindowSize.convertedHeight(1);
    p_ll.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
    profileimage_fl.setLayoutParams(p_ll);
    profileimage_fl.setBackgroundColor(Color.LTGRAY);

    ImageView profileimage = new ImageView(getSherlockActivity());
    layoutWidth = WindowSize.convertedHeight(150);
    layoutHeight = WindowSize.convertedHeight(150);
    p_fl = new FrameLayout.LayoutParams(layoutWidth, layoutHeight);
    profileimage.setLayoutParams(p_fl);
    profileimage.setScaleType(ScaleType.FIT_CENTER);
    profileimage.setPadding(WindowSize.convertedWidth(0),
            WindowSize.convertedHeight(0), WindowSize.convertedHeight(0),
            WindowSize.convertedWidth(0));

    profileimage_fl.addView(profileimage);

然后我将profileimage_fl添加到我在布局中充气的视图组中。该布局xml仅包含该视图组。你看,我通常不使用xml。

0 个答案:

没有答案