44import android .content .Context ;
55import android .content .DialogInterface ;
66import android .util .DisplayMetrics ;
7+ import android .util .TypedValue ;
78import android .view .Gravity ;
89import android .view .View ;
910import android .view .ViewGroup ;
@@ -35,6 +36,7 @@ public interface FileSelectCallback {
3536 private final List <File > selectedFiles = new ArrayList <>();
3637 private AlertDialog dialog ;
3738 private FileListAdapter adapter ;
39+ private int itemTvSize =20 ;
3840
3941 private float widthRatio = 1f ;
4042 private float heightRatio = 1f ;
@@ -45,6 +47,13 @@ public FileDialogSelectUtils(Context context, File startDir, FileSelectCallback
4547 this .callback = callback ;
4648 }
4749
50+ public FileDialogSelectUtils setSizeRatio (float widthRatio , float heightRatio ,int itemTvSize ) {
51+ this .widthRatio = widthRatio ;
52+ this .heightRatio = heightRatio ;
53+ this .itemTvSize = itemTvSize ;
54+ return this ;
55+ }
56+
4857 public FileDialogSelectUtils setSizeRatio (float widthRatio , float heightRatio ) {
4958 this .widthRatio = widthRatio ;
5059 this .heightRatio = heightRatio ;
@@ -160,7 +169,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
160169 layout .setGravity (Gravity .CENTER_VERTICAL );
161170
162171 TextView nameView = new TextView (context );
163- nameView .setTextSize (20 );
172+ nameView .setTextSize (TypedValue . COMPLEX_UNIT_SP , itemTvSize );
164173 nameView .setText (file .getName ().equals (".." ) ? context .getString (R .string .iot_back_directory ) : file .getName ());
165174 nameView .setLayoutParams (new LinearLayout .LayoutParams (0 , ViewGroup .LayoutParams .WRAP_CONTENT , 1 ));
166175 layout .addView (nameView );
0 commit comments