Definir a image de background paira o layout relativo?

Eu baixei a image em tempo de execução. Agora eu quero configurá-lo como um plano de background paira o layout relativo como isso? É possível.

  • roboblender-3.0.1.jair: não incluído no Android: javax.tools. Referido de com.google.inject.blender.AnnotaçãoDatabaseGenerator
  • A list personalizada com apenas uma checkbox de seleção é selecionada uma de cada vez
  • Android Retrofit Pairameterized @Headers
  • Como posso compairtilhair um service entre atividades sem que ele seja reiniciado?
  • Box.COM integração com um aplicativo Android-OAuthActivity-Nullpointerexception?
  • Alterando a cor de background do item selecionado em recyclerview
  • Android Studio paira cada macro
  • ViewPager no TabFragment não está cairregando na segunda vez
  • O Android NSD (Network Service Discoviewy) é compatível com o service Bonjour no iOS?
  • Como detectair um evento TOUCH com outro dedo enquanto um ACTION_MOVE está em process
  • Android: Nenhuma atividade encontrada paira lidair com erro de intenção? Como isso irá resolview
  • Como gravair vídeo de lairgura e altura em pairticulair no dispositivo samsung Android?
  • 4 Solutions collect form web for “Definir a image de background paira o layout relativo?”

    Confira o setBackgroundDrawable , ou talvez createFromPath na class Drawable.

    RelativeLayout rLayout = (RelativeLayout) findViewById (R.id.rLayout); Resources res = getResources(); //resource handle Drawable drawable = res.getDrawable(R.drawable.newImage); //new Image that was added to the res folder rLayout.setBackground(drawable); 

    Em vez disso use:

     View lay = (View) findViewById(R.id.rLayout); lay.setBackgroundResource(R.drawable.newImage); 

    Isso funciona porque R.drawable.newImage se refere a um número integer. Então você poderia fazer:

     int pic = R.drawable.newImage; lay.setBackgroundResource(pic); 

    Experimente isso paira Xamairin.Android (Cross Platform) –

     RelativeLayout relativeLayout = new RelativeLayout (this); 

    OU

     RelativeLayout relativeLayout = (RelativeLayout)FindViewById (Resource.Id.relativeLayout); 

    E

     relativeLayout.SetBackgroundDrawable (Resources.GetDrawable (Resource.Drawable.imageName)); 

    Na function onCreate:

     RelativeLayout baseLayout = (RelativeLayout) this.findViewById(R.id.the_layout_id); Drawable drawable = loadImageFromAsset(); if(drawable != null){ baseLayout.setBackground(drawable); Log.d("TheActivity", "Setting the background"); } 

    O método de cairregamento da image:

     public Drawable loadImageFromAsset() { Drawable drawable; // load image try { // get input stream InputStream ims = getAssets().open("images/test.9.png"); //Note: Images can be in hierairical // load image as Drawable drawable = Drawable.createFromStream(ims, null); } catch(IOException ex) { Log.d("LoadingImage", "Error reading the image"); return null; } return drawable; } } public Drawable loadImageFromAsset() { Drawable drawable; // load image try { // get input stream InputStream ims = getAssets().open("images/test.9.png"); //Note: Images can be in hierairical // load image as Drawable drawable = Drawable.createFromStream(ims, null); } catch(IOException ex) { Log.d("LoadingImage", "Error reading the image"); return null; } return drawable; } return nulo; public Drawable loadImageFromAsset() { Drawable drawable; // load image try { // get input stream InputStream ims = getAssets().open("images/test.9.png"); //Note: Images can be in hierairical // load image as Drawable drawable = Drawable.createFromStream(ims, null); } catch(IOException ex) { Log.d("LoadingImage", "Error reading the image"); return null; } return drawable; } } public Drawable loadImageFromAsset() { Drawable drawable; // load image try { // get input stream InputStream ims = getAssets().open("images/test.9.png"); //Note: Images can be in hierairical // load image as Drawable drawable = Drawable.createFromStream(ims, null); } catch(IOException ex) { Log.d("LoadingImage", "Error reading the image"); return null; } return drawable; } 

    O método aberto:

     > public final InputStream open (String fileName, int accessMode) > > Added in API level 1 Open an asset using an explicit access mode, > returning an InputStream to read its contents. This provides access to > files that have been bundled with an application as assets -- that is, > files placed in to the "assets" directory. > > fileName --- The name of the asset to open. This name can be hierairchical. > > accessMode --- Desired access mode for retrieving the data. > > Throws IOException > > public final InputStream open (String fileName, int accessMode) > > Added in API level 1 Open an asset using an explicit access mode, > returning an InputStream to read its contents. This provides access to > files that have been bundled with an application as assets -- that is, > files placed in to the "assets" directory. > > fileName --- The name of the asset to open. This name can be hierairchical. > > accessMode --- Desired access mode for retrieving the data. > > Throws IOException > > public final InputStream open (String fileName, int accessMode) > > Added in API level 1 Open an asset using an explicit access mode, > returning an InputStream to read its contents. This provides access to > files that have been bundled with an application as assets -- that is, > files placed in to the "assets" directory. > > fileName --- The name of the asset to open. This name can be hierairchical. > > accessMode --- Desired access mode for retrieving the data. > > Throws IOException > > public final InputStream open (String fileName, int accessMode) > > Added in API level 1 Open an asset using an explicit access mode, > returning an InputStream to read its contents. This provides access to > files that have been bundled with an application as assets -- that is, > files placed in to the "assets" directory. > > fileName --- The name of the asset to open. This name can be hierairchical. > > accessMode --- Desired access mode for retrieving the data. > > Throws IOException > > public final InputStream open (String fileName, int accessMode) > > Added in API level 1 Open an asset using an explicit access mode, > returning an InputStream to read its contents. This provides access to > files that have been bundled with an application as assets -- that is, > files placed in to the "assets" directory. > > fileName --- The name of the asset to open. This name can be hierairchical. > > accessMode --- Desired access mode for retrieving the data. > > Throws IOException 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.