can url be used to set background for framelayout ?
Example: I want to use this URL as this as the background of the framelayout .
what I really want to achieve is that when my activity loads, it will extract the image from my domain and use it as the background image of the framelayout. I was able to do this, but I used the image and button.
below is the code I'm using:
public class MyAppActivity extends Activity { ImageView imView; String imageUrl= "http://www.mydomain.com/resource/images/"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button bt3= (Button)findViewById(R.id.postbutton); bt3.setOnClickListener(getImgListener); } View.OnClickListener getImgListener = new View.OnClickListener() { public void onClick(View view) { downloadFile(imageUrl+"image"+".png"); Log.i("im url",imageUrl+"image"+".png"); } }; Bitmap bmImg; void downloadFile(String fileUrl){ URL myFileUrl =null; try { myFileUrl= new URL(fileUrl); } catch (MalformedURLException e) {
, and here are my XML codes:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/rakistaradiobg" android:orientation="vertical" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="98dp" android:layout_gravity="bottom|center" android:scaleType="fitXY" android:src="@drawable/btnbg" /> <Button android:id="@+id/postbutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="Button" />
HeartlessArchangel
source share