mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
android search field use icon instead of text
This commit is contained in:
parent
3f222cb3ff
commit
7e35cb09c3
@ -16,19 +16,7 @@
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/articleSearchLabel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@android:style/TextAppearance.Large"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:text="@string/search_label"
|
||||
/>
|
||||
|
||||
<AutoCompleteTextView
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/articleSearchTextView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -138,11 +138,14 @@ public class KiwixMobileActivity extends Activity {
|
||||
articleSearchBar = (LinearLayout) findViewById(R.id.articleSearchBar);
|
||||
articleSearchtextView = (AutoCompleteTextView) findViewById(R.id.articleSearchTextView);
|
||||
|
||||
final Drawable clearIcon = getResources().getDrawable(R.drawable.navigation_cancel);
|
||||
final Drawable clearIcon = getResources().getDrawable(R.drawable.navigation_cancel);
|
||||
final Drawable searchIcon = getResources().getDrawable(R.drawable.action_search);
|
||||
articleSearchtextView.measure(MeasureSpec.UNSPECIFIED,MeasureSpec.UNSPECIFIED);
|
||||
int height = articleSearchtextView.getMeasuredHeight()-articleSearchtextView.getPaddingTop()-articleSearchtextView.getPaddingBottom();
|
||||
clearIcon.setBounds(0, 0, height, height);
|
||||
articleSearchtextView.setCompoundDrawables(null, null, articleSearchtextView.getText().toString().equals("") ? null : clearIcon, null);
|
||||
searchIcon.setBounds(0, 0, height, height);
|
||||
articleSearchtextView.setCompoundDrawablePadding(5);
|
||||
articleSearchtextView.setCompoundDrawables(searchIcon, null, articleSearchtextView.getText().toString().equals("") ? null : clearIcon, null);
|
||||
articleSearchtextView.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
@ -154,7 +157,7 @@ public class KiwixMobileActivity extends Activity {
|
||||
}
|
||||
if (event.getX() > articleSearchtextView.getWidth() - articleSearchtextView.getPaddingRight() - clearIcon.getIntrinsicWidth()) {
|
||||
articleSearchtextView.setText("");
|
||||
articleSearchtextView.setCompoundDrawables(null, null, null, null);
|
||||
articleSearchtextView.setCompoundDrawables(searchIcon, null, null, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -162,7 +165,7 @@ public class KiwixMobileActivity extends Activity {
|
||||
articleSearchtextView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
articleSearchtextView.setCompoundDrawables(null, null, articleSearchtextView.getText().toString().equals("") ? null : clearIcon, null);
|
||||
articleSearchtextView.setCompoundDrawables(searchIcon, null, articleSearchtextView.getText().toString().equals("") ? null : clearIcon, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user