Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, actually I can't understand, why you use <code>TextView</code> class as you content view. In that case, you can, offcourse, make you own textview extending default one and create particular layout with imageview for it, but, the easiest (and more logical) way is to create lauout file for your activity with <code>TextView</code> and <code>ImageView</code>. </p> <p>For example, it can be something like that:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/myImageView" android:layout_width="wrap_parent" android:layout_height="wrap_content" /&gt; &lt;TextView android:id="@+id/myTextView" android:layout_width="match_parent" android:layout_height="wrap_content" /&gt; </code></pre> <p></p> <p>And your activity onCreate method will be looks something like:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(textView); Intent recieve = getIntent(); String message = recieve.getStringExtra(MainActivity.EXTRA_MESSAGE); TextView textView = (TextView) findViewById(R.id.myTextView); textView.setTextSize(40); textView.setText(message); ImageView imageView = (ImageView) findViewById(R.id.myImageView); </code></pre> <p>}</p> <p>You need to call setContentView <strong>before</strong> finding views by id. </p> <p>If you have to create texview dynamic, from java (I can't see any reason for it from your code) you can add <strong>id</strong> property to <code>LinearLayout</code> and than find it by id and add texview to that, and it will be placed after imageview. </p> <p>p.s. Actually there are a lot of ways to do that, please, define your question more preciselly if my answer doesn't suits you</p> <p>p.p.s. If you really have to create textView in runtime and you can't use xml layouts, you can create <code>LinearLayout</code> in runtime (<code>LinearLayout layout = new LinearLayout(this)</code> and after that, create textView and ImageView and add that two views to that layout, after that make set this layout as content view for the activity</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload