다음과 같이 UI를 디자인하고 있습니다. 보기 1은 이미지이므로 다른 그림을 표시 할 때 크기가 달라집니다. 보기 2와보기 3의 크기는보기 1에 따라 달라집니다. 이렇게하려면 xml 파일을 정의하는 방법?보기의 크기를 다른보기의 크기에 따라 결정하는 방법은 무엇입니까?
ps : 설계가 클라이언트에서 제공되었으므로 변경할 수 없습니다.
다음과 같이 UI를 디자인하고 있습니다. 보기 1은 이미지이므로 다른 그림을 표시 할 때 크기가 달라집니다. 보기 2와보기 3의 크기는보기 1에 따라 달라집니다. 이렇게하려면 xml 파일을 정의하는 방법?보기의 크기를 다른보기의 크기에 따라 결정하는 방법은 무엇입니까?
ps : 설계가 클라이언트에서 제공되었으므로 변경할 수 없습니다.
더 나은 사용 RelativeLayout의는 ....이 작업을 달성 적절한 변경을 확인하고 적절한 크기를 설정하는 가장 쉬운 방법이기 때문에 내가있는 LinearLayout 여기에 더 나은 생각
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_below="@id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_toRightof="@id/view1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"/>
</RelativeLayout>
를 사용하는 layout_weight를 사용합니다. LinearLayout에서 하나의 요소에만 0이 아닌 가중치를 설정하면 나머지 모든 공간이 사용됩니다. layout_weight는 나머지 공간을 주어진 가중치의 비율로 나눕니다. 주어진 layout_width-s (또는 height)를 먼저 설정 한 후에 남아있는 공간의 크기를 계산 한 다음이 크기를 덮어 씁니다. 몇 가지 초기 설정 후에 전체 화면을 고정 비율로 분할하고 남은 공간을 나누고 싶을 때는 먼저 요소의 크기를 0으로 설정해야합니다. View1의 크기를 wrap_content로 설정하고 적절한 방향을 0으로 설정하고 (다른 방향으로 부모를 채움) layout_weight = 1을 사용합니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical" android:layout_width ="wrap_content"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src=.../>
<SomeKindOfView
android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"/>
</LinearLayout>
<AnotherView
android:id="@+id/view3"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_weight="1"/>
</LinearLayout>