android


How to properly set the column count/cell size of StaggeredGrid based on screen configuration


I'm using the AndroidStaggeredGrid by Etsy and want to support different screens by providing appropriate columns count and cell size. Each cell of the grid contains an ImageView and some text.
Following the official documentation (screens support and screen sizes) I create the following folder structure:
values/
integers.xml
values-small/
integers.xml
values-large/
integers.xml
values-xlarge/
integers.xml
The content of integers.xml is as follows (for each configuration I just change the value):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="grid_column_count">2</integer>
</resources>
Then in the layout (I have one layout folder) xml file I configure AndroidStaggeredGrid as follows:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.etsy.android.grid.StaggeredGridView
android:id="#+id/grid_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:item_margin="8dp"
app:column_count="#integer/grid_column_count" />
<ViewStub
android:id="#android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout="#layout/empty_view"/>
</FrameLayout>
My problem is how I can select the right size of the image (I've different sizes: 61*91, 120*178, 180*266, 510*755) to download and show based on the screen density?

Related Links

javax.net.ssl.SSLException: Write error: I/O error during system call, Connection reset by peer
Set compass direction in android
How to get NFC working on Android using Qt 5.6
setDestinationInExternalPublicDir and getExternalStorageDirectory not equal
Adjust view size inside viewpager, make up for tab height
Failure delivering result ResultInfo{} to activity for some pictures
Setup Custom Dialog with ListView
How to programatically issue a click event on Android
Android: How To Fix TextView side by side?
PERMISSION DENIAL: opening provider that is not exported from uid 10083
Equivalent of OnMouseUp() in Unity3D
Android Studio RelativeLayout ScrollView icon overrapping text views
Using trained Scikit-learn svm classifiers in Android [closed]
Keep track of objects using a UUID for immediate user feedback during network requests
Custom support.v7.widget.Toolbar not showing on device
How to open a phoning pop up on clicking a maps marker in android?

Categories

HOME
android
uml
google-cloud-platform
localization
design-patterns
c++11
apache-jena
zend-framework
components
obfuscation
graphics
devise
seo
xbee
permissions
dojo
hugo
ado.net
iis-6
nfs
rcloud
github-enterprise
datastage
php-5.6
plink
qsqlquery
libusb
altera
esoteric-languages
microsoft-ocr
asciidoctor-pdf
squashfs
spring-async
pagespeed
pchart
ckfinder
tiki-wiki
browser-sync
magento-1.8
scrollview
event-flow
record
left-join
angularjs-material
fstream
sammy.js
openwhisk
getpixel
roblox
video-capture
hivemq
magento-1.9.2.4
cin
android-ibeacon
install.packages
glm-math
bindingnavigator
angular-http
magento-2.0.7
user-defined-fields
carrot2
truezip
flyout
google-photos
gameplay-kit
mathcad
filenet
renaming
pocketsphinx-android
atlas
mapxtreme
jquery-jscrollpane
delta
eigenvector
database-relations
nio2
rasterize
relativelayout
rubaxa-sortable
liquid-layout
canvg
procedural-programming
iiop
structuremap3
formview
template-deduction
scriptaculous
http-status-code-410
android-sdk-2.3
frameworkelementfactory
listitem
garbage
database-create
httponly
mtu
object-database
filesystemobject
strtod
dojo-dnd
escrow
unmanagedresources
online-storage

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App