Note that there are some explanatory texts on larger screens.

plurals
  1. POi have horizantal scrollview images,when i was drag the image down i will show button,drag and drop option working only for last image
    primarykey
    data
    text
    <p>I have horizantal scrollview with images,when i was drag the image down i will show button,drag and drop option working only for last image.how can i implement when i was dragging the any image it works.how can i implement this please help me.is any mistake my code please help me.</p> <p>my main activity</p> <pre><code> public class MainActivity extends Activity { // mainLayout is the child of the HorizontalScrollView ... private LinearLayout mainLayout; private TextView text; LinearLayout ll; int status = 0; int Measuredwidth = 0, MeasuredHeight = 0; float x = 0; boolean first = true; Bitmap icon; Button b; ImageView img = null; // this is an array that holds the IDs of the drawables ... //interger array for taking private int[] images = { R.drawable.dd, R.drawable.ss, R.drawable.hh, R.drawable.kk, R.drawable.gg }; View cell = null; /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.activity_main); mainLayout = (LinearLayout) findViewById(R.id.linearLayout); for (int i = 0; i &lt; images.length; i++) { //to inner xml file by using integer image array cell = getLayoutInflater().inflate(R.layout.image, null); img = (ImageView) cell.findViewById(R.id.imageView); img.setImageResource(images[i]); //adding all images mainLayout.addView(cell); } // getting screen width and height Point size = new Point(); WindowManager w = getWindowManager(); if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB_MR2) { w.getDefaultDisplay().getSize(size); MeasuredHeight = size.y; Measuredwidth = size.x; } else { Display d = w.getDefaultDisplay(); Measuredwidth = d.getWidth(); MeasuredHeight = d.getHeight(); } AbsoluteLayout aalayout = (AbsoluteLayout) cell .findViewById(R.id.absLayout); //touch in absolute array means touch the image aalayout.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub //moving for action down and up if (event.getAction() == MotionEvent.ACTION_UP) { status = 0; // img.setBackgroundColor(Color.TRANSPARENT); } //for action down else if (event.getAction() == MotionEvent.ACTION_DOWN) { if (first) { x = event.getX(); first = false; } } //for action up else if (event.getAction() == MotionEvent.ACTION_MOVE) { // } //for checking the screen boundaries if ((event.getX() &lt; (Measuredwidth - img.getWidth() / 2) &amp;&amp; event .getX() &gt; (img.getWidth() / 2)) &amp;&amp; (event.getY() &lt; MeasuredHeight - (img.getHeight() + 60) &amp;&amp; event.getY() &gt; img .getHeight() / 2)) { @SuppressWarnings("deprecation") //setting x and y values AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, (int) 0, (int) event .getY() - img.getHeight() / 2); //seeting moments to image img.setLayoutParams(params); } return true; } }); } } </code></pre> <p>my main 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;HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dip" &gt; &lt;LinearLayout android:id="@+id/linearLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;/LinearLayout&gt; &lt;/HorizontalScrollView&gt; &lt;/LinearLayout&gt; </code></pre> <p>my inner xml:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /&gt; &lt;AbsoluteLayout android:id="@+id/absLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dip" &gt; &lt;ImageView android:id="@+id/imageView" android:layout_width="wrap_content" android:layout_height="wrap_content" &gt; &lt;/ImageView&gt; &lt;/AbsoluteLayout&gt; &lt;/FrameLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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