I m using listfragment in my app. When the data fails to load I call setEmptyText with the failure message. This works fine on 4 inch phones but on 7 and 10 inch phones the size of the empty textview is very small and hard to read.
4 inch empty text view
7 inch empty text view
How can I increase the size of empty text view?
You can provide your own TextView
to be used as the "empty text", it just needs to have android:id="@id/android:empty"
and the ListFragment
will use it instead of the standard one.
You could then customize the style of this TextView however you like (either statically in the xml layout):
<TextView android:id="@id/android:empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="... />
or by calling findViewById()
in onCreateView()
:
TextView emptyTextView = (TextView)view.findViewById(android.R.id.empty);
emptyTextView.setTextSize(...);
A (very good) alternative, as @Delblanco commented, is to call getListView().getEmptyView()
. It will return either the TextView
with id android.R.id.empty
(if supplied in the layout), or the standard TextView
that is used otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With