Giter Site home page Giter Site logo

透明Fragment about fragmentation HOT 4 CLOSED

yokeyword avatar yokeyword commented on May 19, 2024
透明Fragment

from fragmentation.

Comments (4)

LittleWaver avatar LittleWaver commented on May 19, 2024 1

刚才又查看了下issue,新版本的fragment中这个方法可以用来实现:extraTransaction().startDontHideSelf(fragment)

from fragmentation.

YoKeyword avatar YoKeyword commented on May 19, 2024

@duchengzhen 你的Fragment复写下int getWindowBackground()方法,这个方法是取windowBackground背景的,你复写直接返回你的背景资源即可(注:int是资源id,不是color)

from fragmentation.

YoKeyword avatar YoKeyword commented on May 19, 2024

@duchengzhen 我在检查代码的时候发现,其实你只要给Fragment的根布局设置 background,Fragmentation就不会把背景设为windowBackground的了:
if (view != null && view.getBackground() == null) { int background = getWindowBackground(); view.setBackgroundResource(background); }

但是你想通过设置背景色是透明,并通过该Fragment看到下面的Fragment视图,直接设置透明背景并不会直接起作用,因为透过该Fragment看到的是Activity的背景色或者是windowBackground;
原因在于你start了Fragment后,上一个Fragment的视图就是GONE的了;

你可以通过以下代码让上一个Fragment的视图暂时变为看见,这样就可以达到通过当前透明Fragment可以看到前一个Fragment的视图了:
getPreFragment().getView().setVisibility(View.VISIBLE);

from fragmentation.

duchengzhen avatar duchengzhen commented on May 19, 2024

非常感谢,还是源码和fragment理解不透彻的原因

在 2016-05-20 21:26:44,"YoKey" [email protected] 写道:

@duchengzhen 我在检查代码的时候发现,其实你只要给Fragment的根布局设置 background,Fragmentation就不会把背景设为windowBackground的了:
if (view != null && view.getBackground() == null) {
int background = getWindowBackground();
view.setBackgroundResource(background);
}

但是你想通过设置背景色是透明,并通过该Fragment看到下面的Fragment视图,直接设置透明背景并不会直接起作用,因为透过该Fragment看到的是Activity的背景色或者是windowBackground;因为你start了Fragment后,上一个Fragment的视图就是INVISIBLE的了;

你可以通过以下代码让上一个Fragment的视图暂时变为看见,这样就可以达到通过当前透明Fragment可以看到前一个Fragment的视图了:

getPreFragment().getView().setVisibility(View.VISIBLE);


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

from fragmentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.