Tôi đang sử dụng PlaceAutocompleteFragment được cung cấp bởi google trong một dự án mà tôi đang làm việc ngay bây giờ. Nhưng vấn đề là tôi cần hiển thị tên địa điểm mà tôi đã chọn từ tiện ích tự động điền nhưng toàn bộ văn bản không hiển thị vì văn bản mặc định trong tiện ích con quá lớn. Vì vậy, có cách nào tôi có thể thay đổi văn bản trong PlaceAutocompleteFragment mà không cần tạo giao diện người dùng tìm kiếm tùy chỉnh của riêng tôi không?Làm thế nào để thay đổi kích thước văn bản ở những nơi tự động hoàn thành trong android?
Mã của tôi XML:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.baldysns.capedbaldy.materialdesigntest.activity.DrawerMainActivity"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/container_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay">
<LinearLayout
android:id="@+id/lnr_google_searchbar"
android:layout_width="match_parent"
android:layout_height="35dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@drawable/btn_white_notboerder">
<fragment
android:id="@+id/place_autocompletehome_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
</LinearLayout>
<FrameLayout
android:id="@+id/container_body"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
<fragment
android:id="@+id/fragment_navigation_drawer"
android:name="com.ibaax.com.ibaax.FragmentDrawer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_drawer"
tools:layout="@layout/fragment_drawer" /></android.support.v4.widget.DrawerLayout>
Và một ảnh chụp màn hình của vấn đề:
Điều gì xảy ra nếu 'placeAutocompleteFragment' của tôi nằm trong' Linear Layout' và tôi cần đặt văn bản thành 'placeAutocompleteFragment' vì điều này không hoạt động trong trường hợp này. Bất kỳ đề xuất. –
Nó không thành công..java.lang.RuntimeException: Không thể bắt đầu hoạt động ComponentInfo java.lang.ClassCastException: android.widget.LinearLayout không thể truyền tới android.widget.EditText –
@dontknow có thể bạn đang sử dụng id khác hoặc từ các đoạn khác nhau lượt xem. xin vui lòng kiểm tra lại. – Bharatesh