如何在android中的地方autocompletefragment中更改文本大小? [英] How to change text size in places autocompletefragment in android?

查看:14
本文介绍了如何在android中的地方autocompletefragment中更改文本大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 google 提供的 PlaceAutocompleteFragment 在我正在处理的项目中.但问题是我需要显示我从自动完成小部件中选择的地名,但由于小部件中的默认文本大小太大,整个文本没有显示.那么,有什么方法可以在不创建自己的自定义搜索 UI 的情况下更改 PlaceAutocompleteFragment 中的文本大小?

我的 XML 代码:

解决方案

使用片段实例,您可以更改字体大小以及使用搜索框 EditText.. 这就是您需要的方式做

//placeAutocompleteFragment - 是我的 PlaceAutocompleteFragment 实例((EditText)placeAutocompleteFragment.getView().findViewById(R.id.place_autocomplete_search_input)).setTextSize(10.0f);

更新日期:20 年 5 月 26 日

看起来在最新的 SDK 视图中 id 已更改为 R.id.places_autocomplete_search_input

I am using the PlaceAutocompleteFragment that is provided by google in a project that I am working on right now. But the problem is I need to display the place name that I've selected from the autocomplete widget but the whole text in not showing because the default textsize in the widget is too big. So, is there any way I can change the textsize in the PlaceAutocompleteFragment without creating my own custom search UI?

My XML code:

<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>

And a screenshot of the problem:

解决方案

Using fragment instance you can change the font size and whatever you want with the Search box EditText.. this is how you need to do

// placeAutocompleteFragment - is my PlaceAutocompleteFragment instance
((EditText)placeAutocompleteFragment.getView().findViewById(R.id.place_autocomplete_search_input)).setTextSize(10.0f);

UPDATED: 05/26/20

Looks like in latest SDK view id is changed to R.id.places_autocomplete_search_input

这篇关于如何在android中的地方autocompletefragment中更改文本大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆