activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#004444" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp"
android:textColor="#000"
android:text="saturday"
/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="200dp"
android:layout_height="200dp"
/>
</LinearLayout>
//put any image to res/drawable folder
MainActivity.java
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import android.app.Activity;
import android.graphics.Color;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//set layout
setContentView(R.layout.activity_main);
//initialize text view object
TextView tv=(TextView)findViewById(R.id.textView1);
//set text color
tv.setTextColor(Color.RED);
//set text
tv.setText("This is my first app");
//initialize image view object
ImageView im=(ImageView)findViewById(R.id.imageView1);
//set image resource
im.setImageResource(R.drawable.myimage);
}
}
Comments
Post a Comment