I'm working on this app, which basically displays an image and some text. background looks like this http://ift.tt/1Jlq2ml
Now,I have literally set the background of my activity as this image. And I want to implement a function where I can click a button and some stored image would be imported and placed and fit in the WHITE space, and also display some text in the BLACK space.
Any ideas how I would do that ?
package self.name.firstandroidprogram;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Class2 extends Activity {
LinearLayout layout1;
TextView text1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
layout1 = new LinearLayout(this);
text1 = new TextView(this);
text1.setText("RedNet");
layout1.setBackgroundResource(R.drawable.rn);
layout1.addView(text1);
setContentView(layout1);
}
}
And here is my xml
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="self.name.firstandroidprogram.Class2" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
Aucun commentaire:
Enregistrer un commentaire