I have an activity.xml
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
(sometimes too right, sometimes too left)
I have tried to add/remove margine to its left.
But it didn't help.
Where should I look around?
<com.w.navigate.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" />
<ImageButton
android:id="@+id/searchButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/search_engine_button"
android:onClick="engineClicked" />
</LinearLayout>
</com.w.navigate.SearchButtonsBarHorizontalScrollView>
Maybe the fix should be in the 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;
}