在placeautococtletefragment中可见关闭按钮(x标记)



我想在用于显示位置的placeautococtetefragment中可见关闭按钮(x mark)。我该如何实现。

下面是XML片段:

<android.support.v7.widget.CardView
            android:id="@+id/cardview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone">
            <fragment
                android:id="@+id/autocomplete_fragment_second"
                android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
        </android.support.v7.widget.CardView>
PlaceAutocompleteFragment mAutoCompleteFragment = (PlaceAutocompleteFragment)
            getFragmentManager().findFragmentById(R.id.feed_place_autocomplete_fragment);
ViewGroup autoCompleteFragmentView = (ViewGroup) mAutoCompleteFragment.getView();
    int clearButtonId = com.google.android.gms.R.id.place_autocomplete_clear_button;
    View mClearAutoCompleteButton = autoCompleteFragmentView.findViewById(clearButtonId);

这是您获得该按钮的引用的方式,现在您可以根据需要更改其可见性。

我可以用技巧来解决它:)

autocompleteFragment.getView().findViewById(R.id.place_autocomplete_clear_button).setPadding(0,0,0,55555);

最新更新