1
이것은 큰 XML 파일의 축약 된 버전이며, 여기에 표시된 열 중 단 하나만 있습니다. 현재선형 레이아웃으로 이미지 가운데 맞추기
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="4" >
<!-- 1st colum -->
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff0000"
android:orientation="vertical"
android:weightSum="4" >
<ImageButton
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:layout_weight="1"
android:background="@null"
android:scaleType="fitCenter"
android:src="@drawable/myimage" />
</LinearLayout>
<!-- 2nd colum -->
<!-- 3rd colum -->
<!-- 4th colum -->
</LinearLayout>
가 다음과 같이 배치되어
내 질문
1) 왜 늘 빨간색 화면 영역의 중간에 이미지 센터에도 불구하고 이미지 버튼에 android:gravity="center"
을 사용하셨습니까?
2) 어떻게 그 열에 센터링 하시겠습니까?
덕분에 완벽하게 작동했습니다. – oat
사실 내 안드로이드 코드로 놀았지만 이미지 버튼에는 'android : layout_gravity = "center"가 필요하지 않습니다. LinearLayout에 중력을 설정하면 x 및 y 방향을 모두 고려합니다. – ArmaAK