diff options
author | Andrew Dolgov <[email protected]> | 2013-10-16 10:53:55 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-10-16 10:53:55 +0400 |
commit | 49ba455f85d50dd313c282431b4a31de5bee4593 (patch) | |
tree | 464d23611c22c94629feaf5f1504853e0c4ef050 /src | |
parent | 17720f23b11667148f5ffaea395d63f9064a16b8 (diff) |
use dp values for padding
Diffstat (limited to 'src')
-rw-r--r-- | src/org/fox/ttcomics/ComicListFragment.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/org/fox/ttcomics/ComicListFragment.java b/src/org/fox/ttcomics/ComicListFragment.java index 910895a..6d01a42 100644 --- a/src/org/fox/ttcomics/ComicListFragment.java +++ b/src/org/fox/ttcomics/ComicListFragment.java @@ -18,6 +18,7 @@ import android.preference.PreferenceManager; import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SimpleCursorAdapter;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -137,10 +138,12 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { if (thumbnail != null) {
View imageholder = v.findViewById(R.id.listimageholder);
+ int padding = dpToPx(2);
+
if (size == SIZE_DIR) {
if (isList && imageholder != null) {
imageholder.setBackgroundResource(R.drawable.border_folder);
- imageholder.setPadding(2, 2, 2, 2);
+ imageholder.setPadding(padding, padding, padding, padding);
} else {
thumbnail.setBackgroundResource(R.drawable.border_folder);
}
@@ -149,7 +152,7 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { if (isList && imageholder != null) {
imageholder.setBackgroundResource(R.drawable.border);
- imageholder.setPadding(2, 2, 2, 2);
+ imageholder.setPadding(padding, padding, padding, padding);
} else {
thumbnail.setBackgroundResource(R.drawable.border);
}
@@ -169,6 +172,12 @@ public class ComicListFragment extends Fragment implements OnItemClickListener { return v;
}
}
+
+ public int dpToPx(int dp) {
+ DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
+ int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT));
+ return px;
+ }
class CoverImageLoader extends AsyncTask<ImageView, Void, Bitmap> {
private ImageView m_thumbnail;
|