Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change SearchView TextSize

Tags:

android

I have the following SearchView implementation in the xml, the text entry has been cut from the top as shown in the below image. No matter what textSize I am putting, nothing changes.

enter image description here

<LinearLayout
   android:orientation="horizontal"
   android:layout_width="match_parent"
   android:layout_height="32dp"
   android:gravity="center_vertical"
   android:layout_marginTop="10dp">
     <SearchView
        android:id="@+id/search_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="12sp"/>
</LinearLayout>
like image 752
casillas Avatar asked Dec 24 '22 17:12

casillas


1 Answers

You can achieve this using a theme:

in styles.xml

<style name="AppSearchView" parent="Widget.AppCompat.SearchView" >
        <item name="android:textSize">60sp</item>
    </style>

And using a SearchView

<android.support.v7.widget.SearchView
            android:id="@+id/searchView"
            android:layout_width="350dp"
            app:theme="@style/AppSearchView" // use app:theme not in style
            android:layout_height="80dp"
            android:layout_marginTop="15dp"/>
like image 121
Akash Dubey Avatar answered Jan 13 '23 15:01

Akash Dubey