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

Diffrent xhdpi dimens.xml
Android - Using volley and not getting a response
Android Pay: what should be 3dsEciIndicator value when decrypted Android Pay payment token doesn't provide one in case of Network Token
Save message using SmsManager Android Api [duplicate]
How can I read/write files in Android/iOs devices subdirectories using Cordova File Plugin?
StaggeredGridLayoutManager dislocation (2)
Push notification with buttons appcelerator (Android and iOS)
android parse xml from url
How to add datepicker onclick of a TextViiew. Have multiple date fields in the form
Any solution for Android Studio slow gradle build and high disk usage?
Android - Retrofit2 - Google app engine - Send image
Android Studio Project - SMSManager not Sending SMS message
view scrolls down to tabhost when fragment opened
AsyncLayoutInflator info?
Zooming text alone inside an android textview
Can I write a system property listener in android?

Categories

HOME
google-app-engine
paraview
datastore
ns-3
mysql-workbench
serialization
apiblueprint
replace
switch-statement
permissions
cq5
regular-language
hpc
bookmarks
title
rcloud
reactive-programming
windows-ce
activecollab
renjin
bitnami
red5
vuejs
forgot-password
lilypond
visual-glitch
poedit
babel
postscript
exploit
monit
definitelytyped
underscore.js
subclass
gp
google-earth
fiware-cygnus
apic
ods
trigonometry
linqpad
claims
openresty
proget
launchctl
tinymce-3
lightning
appdomain
android-testing
google-photos
cd-burning
filenet
materialized-path-pattern
slackware
node-request
cudd
cubism.js
adafruit
windows-azure-queues
gogs
lean
clipboard.js
jtwig
qiime
findfirst
false-sharing
cycle2
qbxml
dynamics-nav-2016
r-package
poppler
dock
wso2greg
airbrake
omnifaces
teamcity-9.1
cakephp-2.7
mmwormhole
code-documentation
cryptographichashfunction
metatrader5
universal-image-loader
angular-carousel
named-parameters
ignite-ui
rcaller
winginx
accesscontrolexception
scrypt
ui-select2
scmmanager
facebook-timeline
chart-director
curb
fusefabric
mapping-by-code
database-create
isa-swizzling
wiimote
android-holo-everywhere
multiplatform
cgbitmapcontextcreate
cac
ie-compatibility-mode
dot-emacs
ajax-polling
opml
scrollbars
nstokenfield
duplex
lobo-cobra
dsoframer
ifilter

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