Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

test: Reply
 
LinkBack Thread Tools
Old July 13th, 2013, 04:53 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Apr 2011
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default horozontal scroll view not accurate

I have an xml layout with my custom view (bottom horizontal scroll view).


In the middle of the view there is a small tirangle showing which is the currently selected box.

The user can move these boxes (buttons) with his finger to the right and to the left.

However the white small arrow doesn't reach to the middle of the box


I have tried to add/remove margine to its left.

But it didn't help.

Where should I look around?



part of the xml:

Code:
     <com.w.n.SearchButtonsBarHorizontalScrollView
            android:id="@+id/searchButtonBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@drawable/engines_bg"
            android:fadingEdge="horizontal"
            android:gravity="center"
            android:padding="0dp"
            android:scrollbars="none" >
    
            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:orientation="horizontal"
                android:paddingTop="25dp" >
    
                <ImageButton
                    android:id="@+id/leftMargin"
                    android:layout_width="110dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/search_engine_button"
                    android:visibility="invisible" />
    
                <ImageButton
                    android:id="@+id/searchButton1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/search_engine_button"
                    android:onClick="engineClicked" />
    
                <ImageButton
                    android:id="@+id/searchButton2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/search_engine_button"
                    android:onClick="engineClicked" />
    
                <ImageButton
                    android:id="@+id/searchButton3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/search_engine_button"
                    android:onClick="engineClicked" />
       </com.w.n.SearchButtonsBarHorizontalScrollView>

Maybe the fix should be in the code of my SearchButtonsBarHorizontalScrollView

Code:
    public boolean onTouchEvent(MotionEvent event) {
    	super.onTouchEvent(event);
    	Log.d("w","ontouchevent");		
    	if (event.getAction()==MotionEvent.ACTION_UP) {
    		Log.d("WAZE","action up");
    		Integer min_dist=null;
    		SearchEngine min_se=null;
    		@SuppressWarnings("unchecked")
    		Map<Object, SearchEngine> engines=(Map<Object, SearchEngine>)getTag(R.id.searchEngines);
    		Iterator<SearchEngine> i=engines.values().iterator();
    		while (i.hasNext()) {
    			SearchEngine tmp_se=(SearchEngine)i.next();
    			int tmp_dist=Math.abs(tmp_se.getButton().getButtonXPosition()-getScrollX()-getWidth()/2);
    			if (min_dist==null || tmp_dist<min_dist) {
    				min_dist=tmp_dist;
    				min_se=tmp_se;
    			}
    		}
    		((SearchActivity)getTag(R.id.searchActivity)).setActiveEngine(min_se);
    	}
    	return true;
    	
    }

Advertisements
elad2109 is offline  
Reply With Quote
sponsored links
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 07:15 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.