을 잃지 않고보기의 크기를 조정 나는이 레이아웃안드로이드 : 위치
<RelativeLayout
android:id="@+id/gameportView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.pepotegames.spotthedifferences.DifferenceView
android:id="@+id/imageA"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/progressBar1"
android:layout_centerHorizontal="true" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="16dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:max="1000"
android:progress="0" />
<com.pepotegames.spotthedifferences.DifferenceView
android:id="@+id/imageB"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/progressBar1"
android:layout_centerHorizontal="true" />
</RelativeLayout>
당신이 볼 수 있듯이, imageA 및 imageB 내의 ProgressBar에 상대적으로 위치를 가지고있다. 문제는 런타임에 ProgressBar의 크기를 조정해야한다는 것입니다. 그 동안 나는 내 사용자 정의보기 onSizeChanged 메소드가 호출 될 때 트리거됩니다 사용자 정의 리스너가 있습니다.
imageA.setOnSizeChangedLister(new DifferenceView.OnSizeChangedListener(){
@Override
public void onResize(){
level.scaleBy(imageA.getScale());
bar.setLayoutParams(new RelativeLayout.LayoutParams(imageA.getWidth(),bar.getHeight()));
}
});
내 바에 새 LayoutParams 집합을 전달하는 것 외에는 모든 것이 잘 작동합니다. 그래서, 어떻게 안드로이드를 잃지 않고 그 진행 막대의 크기를 조정할 수 있습니다 : layout_centerHorizontal = "true"로하고 안드로이드가 : layout_centerVertical이 = "true"로 속성?