A picture in the fragment



  • How do you make a background image in Android fragment? Preferably, semi-transparent.

    Upd.

    I've done it with android:alpha=".5 was all transparent, along with other elements. So how do we do the same opaquely only with the background without touching other elements?



    1. The lamp is responsible for the attribut android:background
    2. That's what we need to do to identify the background of the core element of the fragment. Take his mark and take her background using the athribut from p.1.
    3. For the background to be semi-propelled (if the background is colour) 88 before color. (i.e. #88424242 instead #424242) If the background is a picture, we need to get the root element of the marking. onCreateView fragment, get his background by using getBackground() and make him transparent by means setAlpha(125)

      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
          View v = inflater.inflate(R.layout.ИМЯ_ФАЙЛА_РАЗМЕТКИ, container, false);
          v.getBackground().setAlpha(125);
          ...
          return v;
      }
      


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2