Note that there are some explanatory texts on larger screens.

plurals
  1. PORelative layout inside a scrollview is not working perfectly.
    text
    copied!<p>I am using a relativelayout inside a scrollview,and I am adding views to that relativelayout dynamically.Eventhough the views are more than the screensize its not scrolling. Please help in solving this task.</p> <p>My ScrollView xml:</p> <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" &gt; &lt;ScrollView android:id="@+id/mainScrollView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg" android:fillViewport="true" &gt; &lt;RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Code used for dynamically adding images:</p> <pre><code> if (isOddViewNo) { isOddViewNo=false; final View view= getLayoutInflater().inflate(R.layout.sample, null); iv= (ImageView)view.findViewById(R.id.iv_small); ImageView iv1= (ImageView)view.findViewById(R.id.iv_big); iv.setVisibility(View.VISIBLE); iv1.setVisibility(View.GONE); iv.setImageResource(R.drawable.ic_launcher); iv.setX(x-45); iv.setY(ypos+17); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); view.setLayoutParams(lp); rl.addView(view); x+=100; } else { isOddViewNo=true; final View view= getLayoutInflater().inflate(R.layout.sample, null); iv= (ImageView)view.findViewById(R.id.iv_big); ImageView iv1= (ImageView)view.findViewById(R.id.iv_small); iv.setVisibility(View.VISIBLE); iv1.setVisibility(View.GONE); iv.setImageResource(R.drawable.ic_launcher); // iv.setLayoutParams(new LayoutParams(200,200)); iv.setX(x-45); iv.setY(ypos); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); view.setLayoutParams(lp); rl.addView(view); x+=178; } </code></pre> <p>My inflated sample.xml:</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="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;ImageView android:layout_height="50dp" android:layout_width="50dp" android:id="@+id/iv_small" android:visibility="gone" /&gt; &lt;ImageView android:layout_height="80dp" android:layout_width="80dp" android:id="@+id/iv_big" android:visibility="gone" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>My screenshot:<img src="https://i.stack.imgur.com/NSkZL.jpg" alt="As I showed my screenshot,it has many images below but couldnt able to scroll."></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