Android: setContentView taking up the entire screen
I have the following code in an activity that receives a string from the main activity:
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(20);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
I want to add an image below the textView:
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
android:text="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/serious" />
With the line setContentView, the textview takes up the entire screen. Without the line, the image is displayed, but the string says "false". Any idea?
Read more
stackoverflow.comm
No comments:
Post a Comment