안드로이드 플로팅 뷰 (다른 시야를 통해)
-
20-09-2019 - |
문제
나는 지금 며칠 동안 이것을 엉망으로 만들었습니다. 여기 누군가가 나에게 손을 빌려 줄 수 있기를 바랍니다.
간단한 2 열 레이아웃이 있고 왼쪽은 버튼이있는 탐색 막대이며 오른쪽은 콘텐츠 패널입니다. 사용자가 버튼 중 하나를 두드리면 (예 : 세 번째 버튼),이 버튼의 오른쪽에 부유 한보기를 정렬하지만 콘텐츠 창 위에 떠 다니고 싶습니다. 다음은 내가 의미하는 바를 설명하는 사진입니다.
내가 시도한 모든 것은 내비게이션 막대 나 컨텐츠 패널 내부의 부유 식 메뉴를 흡수합니다. 어떤 아이디어? 기본적으로 내가 지금까지 가지고있는 것은 다음과 같습니다.
<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:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_alignParentLeft="true"
android:id="@+id/navigation_bar"
>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.14"
>
<ImageButton
android:id="@+id/button1_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon"
android:layout_gravity="center"
/>
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.14"
>
<ImageButton
android:id="@+id/button2_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon"
android:layout_gravity="center"
/>
</FrameLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.14"
android:layout_toRightOf="@id/navigation_bar"
>
</FrameLayout>
</RelativeLayout>
해결책
Framelayout을 사용하면 다른 뷰를 겹치는 뷰를 가질 수 있습니다. 당신의 예에서와 같이 하나의 자녀 견해 만 가지고있는 것이 합리적이지는 확실하지 않습니다. "정적"보기를 첫 번째 자식 요소로, 부유 식 메뉴를 두 번째 자식으로 볼 수있는 최고 수준에서 Framelayout을 사용해보십시오.
그만큼 개발자 문서 레이아웃 유형에 대한 개요가 적합하면 시작하는 데 도움이 될 수 있습니다.
다른 팁
RelativeLayout
당신이 원하는 것입니다.
FrameLayout
따라서 자녀가 하나만 있어야하므로 일반적으로 다른 레이아웃이 나중에 오는 자리 표시 자에만 사용됩니다 (예 : 활동의 주요 프레임).
AbsoluteLayout
더 이상 사용되지 않으며 사용해서는 안됩니다.
RelativeLayout
뷰가 겹치고 원하는 모든 것을 허용합니다.