如何设置搜索查看TEXTSIZE? [英] How to set SearchView TextSize?

查看:128
本文介绍了如何设置搜索查看TEXTSIZE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索查看的LinearLayout ,我想设置一个不同的 TEXTSIZE 为它(搜索查看),但设置时,安卓TEXTSIZE =60SP例如,什么都不会发生。

I have a SearchView inside a LinearLayout and I'm trying to set a different TextSize for it (the SearchView) but when setting android:textSize="60sp" for example, nothing happens.

这是我的code:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"
          android:padding="2dp">
<SearchView
        android:id="@+id/searchView"
        android:layout_width="350dp"
        android:textSize="60sp"
        android:layout_height="80dp"
        android:layout_marginTop="15dp"/>
<ListView
        android:id="@+id/search_results"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

有谁知道如何修改的 TEXTSIZE 控制?

Does anyone know how to modify the TextSize of the control?

推荐答案

您可以做这些使用code

You could do these using code

SearchView searchView = new SearchView(context);
LinearLayout linearLayout1 = (LinearLayout) searchView.getChildAt(0);
LinearLayout linearLayout2 = (LinearLayout) linearLayout1.getChildAt(2);
LinearLayout linearLayout3 = (LinearLayout) linearLayout2.getChildAt(1);
AutoCompleteTextView autoComplete = (AutoCompleteTextView) linearLayout3.getChildAt(0);
autoComplete.setTextSize(60);

下面是另一种解决方案

SearchView searchView = new SearchView(context);
AutoCompleteTextView search_text = (AutoCompleteTextView) searchView.findViewById(searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null));
search_text.setTextColor(Color.WHITE);
search_text.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.text_small));

这篇关于如何设置搜索查看TEXTSIZE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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