There are no errors when compiling, but images are not displayed - only three blue squares

java

super.onCreate(savedInstanceState); setContentView(R.layout.inv); TextView textEl = (TextView) findViewById(R.id.textView); int strId = getResources().getIdentifier("article", "string", getPackageName()); String strValue = getString(strId); textEl.setText(Html.fromHtml(strValue)); 

xml

 <string name="article" formatted="false"><![CDATA[ <img src="@res/mipmap-hdpi/ic_launcher"> <img src="@res/mipmap-hdpi/ic_launcher.png"> <img src="file:///С:/Android/testV7/app/src/main/res/qwerty.png"/> 

markup

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Go to Activity One" android:id="@+id/btnActOne"/> </LinearLayout> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Button 1" /> <TextView android:id="@+id/textView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:text="nope"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Button 11" /> </LinearLayout> </ScrollView> </LinearLayout> 
  • Show the markup, maybe you have a small resolution image and the wrap_content is wide and high. - Silento
  • .tak is <TextView android: id = "@ + id / textView" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "50dp" android: text = "nope" /> but mine Not only pictures, but also text with html markup are displayed in textView - kuzmich
  • one
    The "fill_parent" attribute has long been unused. Update the answer along with all the markup available. - Silento
  • I added the code in question - kuzmich
  • There are special buttons called the Image Button or Image View — there is not a single one in your markup. Use them to display images. TextView is not a widget that is used to display photos or other images. - Silento

1 answer 1

I understand you want to put text with pictures in TextView html. TextView do not display pictures, they are intended only for text, for your purposes it is better to use WebView . I also advise html documents to be stored in Assets, a special folder for styles, instead of resources. The simplest use is:

 WebView wv= (WebView)findViewById(R.id.webView1); wv.loadUrl("file:///android_asset/yourfile.html"); 

You can also use document parsing, for example via jsoup, and using it to build an xml file on an android.