각 수평 LinearLayout의 높이를 추측하지 않고 이미지를 터치하는 방법이 있습니까? 당신은 내가이 효과를 얻기 위해 144dp에있는 LinearLayout의 높이를 추측했다 나의 XML에서 볼 수 있듯이Android :이 레이아웃을 얻는 방법
, 다양한 화면 크기에 일하는 것이 더 나은 방법은 무엇입니까?
<LinearLayout
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="144dp" >
<ImageView
android:id="@+id/ImageView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_sport" />
<ImageView
android:id="@+id/ImageView02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_science" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout02"
android:layout_width="match_parent"
android:layout_height="144dp"
android:layout_gravity="fill_horizontal" >
<ImageView
android:id="@+id/imageView03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_science" />
<ImageView
android:id="@+id/imageView04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_sport" />
</LinearLayout>
<LinearLayout
android:id="@+id/LinearLayout03"
android:layout_width="match_parent"
android:layout_height="144dp"
android:layout_gravity="fill_horizontal" >
<ImageView
android:id="@+id/ImageView05"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_sport" />
<ImageView
android:id="@+id/ImageView06"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@drawable/ic_science" />
</LinearLayout>
</LinearLayout>
가능한 경우 XML로 처리하는 것을 선호합니다. 이미지는 정사각형이므로 너비를 채우고 여전히 비례해야합니다. 나는 fitXY로 거의 그것을 할 수있다. 그러나 그것은 단지 그들의 폭이 아니라 그들의 높이를 뻗는다.
어떻게 선형 레이아웃의 높이를 추측하고 있습니까? 선형 레이아웃이 이미지의 높이에 따라 달라지는 높이를 추측하고 있다는 것을 의미합니까? 각 선형 선형 레이아웃을 수직 선형 레이아웃에 넣고 원하는 것을 얻을 수 있습니까? –
이미지가 LinearLayout을 완벽하게 채울 때까지 LinearLayout01의 높이를 늘 렸습니다 (선형 레이아웃이 정사각형이되었습니다) – Edd
@cskoala LinearLayouts를 사용하여 수직선을 만드는 것이 좋습니다. 2 개의 수직의 LinearLayouts의 사이에 약간의 간격을 두어 화면을 수직 방향으로 전부 칠합니다. 아마 scaleXY – Edd