어딘가에 어리석은 실수가 있음을 알고 있지만 어디에서 확인할 수 없습니다. 나는 컨테이너의 코드를 다음있어 :Android Studio에서 사용자 정의 컨테이너에보기를 넣지 않겠습니다.
public class ImagesView extends LinearLayout {
public ImagesView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ImagesView(Context context) {
super(context);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
float ar=(float)896/768;
this.setMeasuredDimension(widthSize, (int) (widthSize/5*(1f/ar)));
//this.setMeasuredDimension(1280,240);
}
}
레이아웃 XML : 안드로이드 스튜디오에서
<?xml version="1.0" encoding="utf-8"?>
<com.rhyboo.net.test.ImagesView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/holo_red_light">
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button3"
android:layout_weight="1" />
</com.rhyboo.net.test.ImagesView>
내 컨테이너의 크기가 올바르게 설정되어 볼 수 있습니다,하지만 난 용기에 무언가를 추가 할 경우이 같은 아이 뷰를 표시 제로 크기 :
내가 뭘 잘못하고 있니?
전체 레이아웃 코드를 제공해주십시오. – MemLeak
예. 내 첫 글을 수정했습니다. 죄송합니다. – undefined