이 내 코드가 FrameLayout
함께 표시되지 않습니다, FrameLayout이 확장.는 아이 뷰는 더 이상
이제 FrameLayout에서 맞춤 레이아웃을 확장했습니다. MyFrameLayout.
는 MyFrameLayout, 나는 레이아웃의 높이가 항상 폭의 절반 원하는, 그래서 내 코드는 지금 내부
<com.test.MyFrameLayout
android:layout_width="fill_parent" android:layout_height="wrap_content">
<ImageView
android:id="@+id/frameView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/image1"
/>
</com.test.MyFrameLayout>
그러나 그런 다음
public class MyFrameLayout extends FrameLayout {
// 3 constructors just call super
@Override
protected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = (int) (width * 0.5);
setMeasuredDimension(width, height);
}
}
XML에서 사용 ImageView가 사라졌습니다.
onMeasure
또는 onLayout
을 올바르게 구현하지 않은 것 같습니다. 아이들 뷰도 크기를 조정해야한다고 생각합니다. 그러나 나는 지금 무엇을 해야할지 모른다.
UPDATE TheDimasig의 코멘트 당
은, 난 그냥 내 코드를 확인하고 내 질문을 업데이트합니다. 감사합니다
두 가지 제안 : 1. MyFrameLayout 클래스에서 onMeasure와 onLayout을 확인하십시오. 2. 디버깅을 위해 hierarhyviewer 도구를 사용해보십시오. 또한, 사용자 정의 레이아웃 –
@TheDimasig의 모든 코드를 표시 할 수 있다면, 제 질문을 업데이트했습니다. 리뷰 : – Freewind