Wow — a new whale has arrived 🐋 #anonim_fw0 a.k.a @Ben_Manlapaz just showed true capability, creating massive waves with 49 #NFTs 🌊🔥 Huge respect and gratitude for bringing such strong energy into the #NFToa ecosystem 🙌 #eCash $XEC #NFTCommunity #NFTCollectors #CryptoMarket pic.twitter.com/mJpkQMU3Su
— NFToa (@nftoa_) September 6, 2025
Hi dev, I want to try to share another strange experience, which is when the font size in my SearchView component is too big, I thought it was easy, just define the properties in the xml layout, eh it turns out it's not that easy ferguso ... when I have implemented the function called android:textSize="60sp" but what happened? there was no change at all, here is my code case at that time.
<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"/>The solution
Turns out, you can do that programmatically, like this.
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);Or, you can also use alternative 1.
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));Or, you can also use style, alternative 2.
<style name="AppSearchView" parent="Widget.AppCompat.SearchView" >
<item name="android:textSize">60sp</item>
</style>then implement.
<android.support.v7.widget.SearchView
android:id="@+id/searchView"
android:layout_width="350dp"
app:theme="@style/AppSearchView"
android:layout_height="80dp"
android:layout_marginTop="15dp"/>Done, good luck!
