我有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。