Android에서 레이아웃 (XML 파일)을 만들고 있습니다. 2 개의 아이 뷰 (화면의 오른쪽에 1 개, 왼쪽에 1 개) 오른쪽에있는보기가 미리 결정된 공간 (dp로)을 차지하고 왼쪽에있는보기가 나머지 공간을 한도까지 차지하게하고, 그 지점에서 확장이 중지되고 두 레이아웃이 화면이 커질수록 더 멀리 움직입니다.왼쪽에 미리 설정된 공간과 뷰를 차지하는 오른쪽의보기가있는 Android 레이아웃은 일정한 한도까지 화면의 나머지 부분을 채 웁니다.
이상한 점은 오른쪽의보기가 펼쳐지는 것이고 왼쪽의보기가 미리 설정된 공간을 차지하기를 원한다면 매우 쉽다는 것입니다. 각 너비를 원하는 너비로 설정하면 (수평 선형 레이아웃에서) 안드로이드는 두보기가 맞지 않을 경우 왼쪽에있는 것을 자동으로 축소합니다.
하나의 레이아웃 파일에서이 작업을 수행하고 싶습니다. 이 레이아웃은 이미 sw512dp-land와 sw765dp-land 사이의 디스플레이 용으로 설계되었습니다.
안드로이드가 왼쪽에서 레이아웃을 축소 할 수있는 방법을 찾으면 아래 코드가 작동합니다 (레이아웃이 둘 다 지정된 크기에 맞지 않을 때). 그러나 기본적으로 시스템은 우선 레이아웃을 축소합니다. 나는에 레이아웃이 필요하지 않은 경우
(@Lokesh에서)이 코드
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/left"
android:layout_width="150dip"
android:layout_height="fill_parent"
android:background="@color/red" >
</RelativeLayout>
<LinearLayout
android:id="@+id/right"
android:layout_width="100dip"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@color/green" >
</LinearLayout>
작동 것이 특정 지점에서 확대 중지 떠났다. 사람이 그래서 난 실용적으로 그 일을하거나 레이아웃에 대한 나의 접근 방식의 변화에 의존 할 수없는 생각하면
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/left"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toLeftOf="@+id/right"
android:background="@color/red" >
</LinearLayout>
<LinearLayout
android:id="@+id/right"
android:layout_width="100dip"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="@color/green" >
</LinearLayout>
또한 알고 좋을 것이다.
감사합니다.
당신이 말하는이 뷰 *가 정확히 무엇입니까? 레이아웃 또는 위젯을 의미합니까? –
게시 코드 – Chaitanya
시도하기 쉬워야하지만, 남아있는 모든 공간을 최대 한도까지 * 차지하는 것이 무엇을 의미하는지에 따라 달라집니다. – Luksprog