program story

FrameLayout은 무엇을합니까?

inputbox 2020. 11. 29. 10:26
반응형

FrameLayout은 무엇을합니까?


저는 프로그래밍이 처음입니다. 그래픽 레이아웃을 사용하고 있었는데 xml 파일을 읽을 때 FrameLayout을 보았습니다. 그런 다음 검색했지만 유용한 것을 찾을 수 없었습니다. FrameLayout은 무엇이며 어떤 역할을합니까?


FrameLayout을 사용하여 하위 뷰를 스택 위에 쌓고 가장 최근의 하위 뷰를 스택 위에 쌓습니다. 아래 예에서 TextView는 가장 최근의 것이므로 자동으로 ImageView 위에 배치됩니다.

예를 들면 :

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/backgroundImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:src="@drawable/bitmapie" />

    <TextView
        android:id="@+id/descTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginTop="70dp"
        android:background="@android:color/holo_blue_light"
        android:padding="10dp"
        android:text="TextView placed at the top of the Imageview"
        android:textColor="@android:color/white"
        android:textSize="22sp" />

</FrameLayout>

산출:

여기에 이미지 설명 입력


FrameLayout단일 항목을 표시하기 위해 화면의 영역을 차단하도록 설계되었습니다. 일반적으로 FrameLayout자식보기가 서로 겹치지 않고 다른 화면 크기로 확장 가능한 방식으로 자식보기를 구성하기 어려울 수 있으므로 단일 자식보기를 유지하는 데 사용해야합니다. 그러나 속성을 사용하여 각 하위에 중력을 할당 하여 a에 여러 하위를 추가 FrameLayout하고 해당 위치를 제어 할 수 있습니다 .FrameLayoutandroid:layout_gravity

하위 뷰는 스택에 그려지며 가장 최근에 추가 된 하위 항목이 맨 위에 표시됩니다.

여기에 이미지 설명 입력

사용에 대한 또 다른 인기있는 접근 방식 FrameLayout:

  • A와 Fragment컨테이너
  • 당신의 관습의 조상으로서 ViewGroup

RelativeLayout 대 ConstraintLayout

여기에서 더 많은 것을 읽으 십시오


Google 검색을 하셨나요?

프레임 레이아웃은 단일 항목을 표시하기 위해 화면의 영역을 차단하도록 설계되었습니다. 일반적으로 FrameLayout은 자식이 서로 겹치지 않고 다른 화면 크기로 확장 가능한 방식으로 자식보기를 구성하기 어려울 수 있으므로 단일 자식보기를 유지하는 데 사용해야합니다.

그러나 여러 자식을 FrameLayout에 추가하고 android : layout_gravity 속성을 사용하여 각 자식에게 중력을 할당하여 FrameLayout 내에서 위치를 제어 할 수 있습니다.

FrameLayout의 비밀은 자식을 레이아웃하는 방법입니다. 일반적으로 하나의 항목을 포함하도록 설계되었지만 다른 요소를 서로 쌓아 올릴 것입니다. 따라서 FrameLayout은 본질적으로 화면에서 뷰의 Z 순서를 조작하는 방법입니다.

This is super useful for a couple of UI tricks from HUD-like elements to sliding panels to more complex animated transitions. In this post we will see an example for each of those.

FrameLayout is designed to display a single item at a time. You can have multiple elements within a FrameLayout but each element will be positioned based on the top left of the screen. Elements that overlap will be displayed overlapping. I have created a simple XML layout using FrameLayout that shows how this works.


단어 frame를 일반 사진 프레임으로 간주 할 수 있습니다 . 그 프레임으로 무엇을합니까? 그 프레임에 사진을 한 겹 위로 올릴 수 있습니다. 동일 같이 FrameLayout우리가 같은 다른 전망 (모든 레이아웃, 또는 위젯 버튼, 텍스트처럼, 이미지 등) 상단을 배치 할 수 있습니다 @ojonugwa 쇼 당신에게 이미지의 텍스트 뷰의 상단.


기본적으로 하나의 뷰를 다른 뷰 위에 놓습니다. 예를 들면 다음과 같습니다.

이미지의 텍스트 부풀림

  <FrameLayout>

<ImageView>
<Textview>

  </FrameLayout>

참고 URL : https://stackoverflow.com/questions/25679369/what-does-framelayout-do

반응형