How to change Layout background dynamically in Android?



I have parsed JSON at the time of Splash screen, in which image url is parsed for background image for login screen. Here is sample XMLcode for login screen:



<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:id="@+id/loginLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_bg" <!-- I want to change this background dynamically. -->
android:focusableInTouchMode="true"
android:gravity="center"
tools:context=".activity.LoginActivity" >

<ScrollView
android:id="@+id/mainScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<!-- .... Here is edit text for login inputs and buttuns for singnup and login. -->

</LinearLayout>
</ScrollView>
</RelativeLayout>


In above i have placed static image in the background of RelativeLayout but i want to make backgroud as changeble according to image url.


Thanks in advance.


No comments:

Post a Comment