У меня есть следующий код в деятельности, которая получает строку от основной деятельности:Android: setContentView занимая весь экран
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);
Я хочу, чтобы добавить изображение ниже TextView
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView android:layout_alignParentLeft="true"
android:text="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/serious" />
</LinearLayout>
С линией setContentView
, TextView
занимает весь экран. Без строки изображение отображается, но строка говорит «false
». Есть идеи?
сейчас, мое приложение падает –
Будьте точны и говорите как разработчик. Какой ответ вы ожидаете, просто говоря: «Мое приложение падает»? Отправьте логарифм, пожалуйста. –