program story

Android에서 겹치는 뷰

inputbox 2020. 10. 22. 08:00
반응형

Android에서 겹치는 뷰


Android에서 겹치는 뷰를 가질 수 있습니까? 전면에 투명한 png가 있고 배경에 다른 뷰가있는 ImageView를 갖고 싶습니다.

편집하다:

이것이 내가 현재 가지고있는 것입니다. 문제는 imageView의 이미지가 투명하지 않고 투명 해야하는 부분이 검은 색이라는 것입니다.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/gallerylayout"
>
<Gallery android:id="@+id/overview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />

 <ImageView android:id="@+id/navigmaske"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/navigmask"
    /> 

</RelativeLayout>

편집하다:

작업에 착수했습니다. 팀의 다른 프로그래머가 만든 테마 파일이었습니다. 방금 변경

<item name="android:background">#FF000000</item>

이에

<item name="android:background">#00000000</item>

Android는 기본적으로 뷰 및 드로어 블 (PNG 이미지 포함)에 대한 투명성을 처리하므로 설명하는 시나리오 (가 ImageView앞에 부분적으로 투명 함 Gallery)가 확실히 가능합니다.

문제가있는 경우 레이아웃 또는 이미지와 관련이있을 수 있습니다. 나는 당신이 설명하는 레이아웃을 복제하고 당신이 추구하는 효과를 성공적으로 달성했습니다. 내가 사용한 정확한 레이아웃은 다음과 같습니다.

<RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/gallerylayout"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <Gallery
    android:id="@+id/overview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
  />
  <ImageView
    android:id="@+id/navigmaske"
    android:background="#0000"      
    android:src="@drawable/navigmask"
    android:scaleType="fitXY"
    android:layout_alignTop="@id/overview"
    android:layout_alignBottom="@id/overview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
  />
</RelativeLayout>

일반적으로 기본 활동에 대해 원하는 RelativeLayout높이와 너비로 부모 변경했습니다 fill_parent. 그럼 상단을 정렬하고, 하단 한 ImageView위로와 하단 Gallery이 그것의 앞에 중심을 보증합니다.

또한의 배경을 ImageView투명하게 설정했습니다.

이미지 드로어 블 자체의 경우 PNG 파일을 내가 볼 수있는 어딘가에두면 내 프로젝트에서 사용할 수 있고 책임이 있는지 확인할 수 있습니다.


Also, take a look at FrameLayout, that's how the Camera's Gallery application implements the Zoom buttons overlay.


If you want to add you custom Overlay screen on Layout, you can create a Custom Linear Layout and get control of drawing and key events. You can my tutorial- Overlay on Android Layout- http://prasanta-paul.blogspot.com/2010/08/overlay-on-android-layout.html


Visible gallery changes visibility which is how you get the gallery over other view overlap. the Home sample app has some good examples of this technique.


The simples way arround is to put -40dp margin at the buttom of the top imageview


Yes, that is possible. The challenge, however, is to do their layout properly. The easiest way to do it would be to have an AbsoluteLayout and then put the two images where you want them to be. You don't need to do anything special for the transparent png except having it added later to the layout.

참고URL : https://stackoverflow.com/questions/961944/overlapping-views-in-android

반응형