<LinearLayout
android:id="@+id/estate_linear"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:layout_weight="1"
android:background="@drawable/border_rounded_gray_white"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_margin="5dp"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/object_btn_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_gravity="center_vertical|right"
android:background="@drawable/btn_search"
android:contentDescription="@null"
android:scaleType="fitXY" />
<RelativeLayout
android:layout_width="1dp"
android:layout_height="33dp"
android:layout_marginLeft="8dp"
android:background="@color/color_line" />
<EditText
android:id="@+id/object_et_content"
style="@style/StringSearchText"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="2dp"
android:layout_marginRight="8dp"
android:layout_weight="1"
android:background="@null"
android:hint="@string/tip_search_hint"
android:imeOptions="actionSend"
android:singleLine="true"
android:textCursorDrawable="@null"
android:textColorHint="#626463" />
<ImageButton
android:id="@+id/object_btn_del"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="10dp"
android:background="@drawable/ic_clear" />
</LinearLayout>
border_rounded_gray_white.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 连框颜色值 -->
<item>
<shape>
<solid android:color="@color/bg_gray" />
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"
android:topLeftRadius="3dp"
android:topRightRadius="3dp" />
</shape>
</item>
<!-- 主体背景颜色值 -->
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp">
<shape>
<solid android:color="@color/white" />
<corners
android:bottomLeftRadius="3dp"
android:bottomRightRadius="3dp"
android:topLeftRadius="3dp"
android:topRightRadius="3dp" />
</shape>
</item>
</layer-list>
<style name="StringSearchText">
<item name="android:textSize">14dp</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@android:color/black</item>
</style>
btn_search.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 没有焦点时的背景图片 -->
<item android:drawable="@drawable/ic_search_normal" android:state_window_focused="false"/>
<!-- 非触摸模式下获得焦点并单击时的背景图片 -->
<item android:drawable="@drawable/ic_search_pressed" android:state_focused="true" android:state_pressed="true"/>
<!-- 触摸模式下单击时的背景图片 -->
<item android:drawable="@drawable/ic_search_pressed" android:state_focused="false" android:state_pressed="true"/>
<!-- 选中时的图片背景 -->
<item android:drawable="@drawable/ic_search_pressed" android:state_selected="true"/>
<!-- 获得焦点时的图片背景 -->
<item android:drawable="@drawable/ic_search_pressed" android:state_focused="true"/>
<!-- 默认图片背景 -->
<item android:drawable="@drawable/ic_search_normal"/>
</selector>
<color name="color_line">#bebebe</color>
private TextWatcher textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
@Override
public void afterTextChanged(Editable s) {
mKeywords = tv_keyword.getText().toString();
AgUtils.log(TAG+"mKeywords:"+mKeywords, 4);
if (TextUtils.isEmpty(mKeywords)) {
object_btn_del.setVisibility(View.GONE);
} else {
object_btn_del.setVisibility(View.VISIBLE);
searchIndexListInfo();
}
}
};
tv_keyword.addTextChangedListener(textWatcher);
posted on 2015-07-08 23:55
Terry Zou 阅读(131)
评论(0) 编辑 收藏 所属分类:
Android