당김 형태로 구성된 사용자 지정보기의 치수 : 나는 실제로 ListView에이를 사용하고 http://developer.android.com/guide/topics/graphics/2d-graphics.html#shape-drawable에서 발견 나는 꽤 많은 샘플을 다음입니다
public class CustomDrawableView extends View {
private ShapeDrawable mDrawable;
public CustomDrawableView(Context context, AttributeSet attr) {
super(context, attr);
int x = 10;
int y = 10;
int width = 300;
int height = 50;
mDrawable = new ShapeDrawable(new OvalShape());
mDrawable.getPaint().setColor(0xff74AC23);
mDrawable.setBounds(x, y, x + width, y + height);
}
protected void onDraw(Canvas canvas) {
mDrawable.draw(canvas);
}
}
// XML snippet where I am using this custom view
<com.example.shapedrawable.CustomDrawableView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
, 그래서는 (내 어댑터의의 getView 방법에 팽창됩니다 나는 그것이 비 - 사용자 정의보기를 위해 잘 보이기 때문에 이것이 작동하는 것을 안다).
layout_width 및 layout_height에 "dp"값을 지정하지 않으면 그다지 드러내지 않는 것으로 나타났습니다. 그러나 layout_width 및 layout_height에 500dp와 같은 임의의 것을 사용하면 나타납니다! 매우 혼란 스럽습니다. wrap_content를 사용할 때 코드에서 지정하는 높이/너비 치수를 사용하지 않는 이유는 무엇입니까?