Why Android layout inflater is inflating blank space? -


i'm trying inflate layout on onpostexectue method of asynctask, nothing gets displayed, think view gets inflated because parent scrollview's size increases. why nothing visible?

here i'm doing in onpostexecute method:

linearlayout rootview = (linearlayout) getactivity().findviewbyid(r.id.root_view); view child = getactivity()                  .getlayoutinflater()                  .inflate(r.layout.layout_child, rootview, false); rootview.addview(child); 

child layout inflated:

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:gravity="center_vertical"     android:orientation="horizontal">      <imagebutton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_margin="20dp"         android:background="@null"         android:src="@drawable/ic_play_arrow_black_24dp" />      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:gravity="center"         android:text="t 1"         android:textsize="30sp" />  </linearlayout> 

parent layout i'm inflating:

<scrollview 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"     tools:context="com.example.abc.detailfragment"     tools:showin="@layout/activity_a">      <linearlayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical"         android:id="@+id/root_view">          <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:orientation="horizontal">              <imageview                 android:id="@+id/poster"                 android:layout_width="139dp"                 android:layout_height="209dp"                 android:layout_margin="10dp" />              <linearlayout                 android:layout_width="match_parent"                 android:layout_height="match_parent"                 android:layout_margin="10dp"                 android:orientation="vertical"                 android:padding="5dp">                  .                 .                 .              </linearlayout>          </linearlayout>          <textview             android:id="@+id/overview"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:textsize="20sp"             android:layout_margin="8dp" />      </linearlayout> </scrollview> 

i no error blank space.

first of all, think should delegate inflating of views activity sake of how you're doing things @ moment, try inflating , adding child in runonuithread.

runonuithread(new runnable() {         public void run() {         linearlayout rootview = (linearlayout) getactivity().findviewbyid(r.id.root_view);         view child = getactivity()                          .getlayoutinflater()                          .inflate(r.layout.layout_child, rootview, false);         rootview.addview(child);     } }); 

also, if know root view linearlayout, why not use instead of view?


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -