Par*_*ala 4 android google-maps navigation-drawer
我有一个使用谷歌地图的Android应用程序,我想要一个看起来就像Android谷歌地图的搜索栏.下面是我的XML代码和我所拥有的图片.
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<fragment
android:id="@+id/place_autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
问题是我从左侧滑动时会打开一个导航抽屉.我想在搜索栏中添加"三条水平线",例如谷歌地图,因此每当您点击它时,导航抽屉就会打开,如下所示.
那么如何将"放大镜"更改为"3条水平线"并使点击导航抽屉打开.谢谢!
您可以找到相应的ImageView并更改它的图标和点击事件:
PlaceAutocompleteFragment placeAutocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
ImageView searchIcon = (ImageView)((LinearLayout)placeAutocompleteFragment.getView()).getChildAt(0);
// Set the desired icon
searchIcon.setImageDrawable(getResources().getDrawable(R.drawable.yourdrawable));
// Set the desired behaviour on click
searchIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MapsActivity.this, "YOUR DESIRED BEHAVIOUR HERE", Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1614 次 |
| 最近记录: |