android


how to change imageView size depending on another item's size?


I have a relative layout which contains 2 items, one being a spinner and an ImageView, how do i set image view ratio based on Spinner height, in this case I set the height of Spinner to wrap_content, so the image can change it's aspect based on spinner's height.
<RelativeLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".28"
android:background="#drawable/spinner_bg"
android:orientation="horizontal">
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:gravity="center"
android:spinnerMode="dropdown" />
<ImageView
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="#mipmap/drop" />
</RelativeLayout>
<RelativeLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".28"
android:background="#drawable/spinner_bg"
android:orientation="horizontal">
<ImageView
android:id="#+id/iv"
android:scaleType="fitXY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_alignTop="#+id/spinner"
android:layout_alignBottom="#+id/spinner"
android:layout_gravity="center"
android:src="#mipmap/drop" />
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/iv"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:gravity="center"
android:spinnerMode="dropdown" />
</RelativeLayout>
<RelativeLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".28"
android:orientation="horizontal">
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:background="#drawable/spinnerbg"
android:gravity="center"
android:spinnerMode="dropdown"
/>
</RelativeLayout>
In Drawable ,you add spinnerbg.xml;
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/InputBg" />
</item>
<item android:gravity="center_vertical|right" android:right="8dp">
<layer-list>
<item android:width="12dp" android:height="12dp" android:gravity="center" android:bottom="10dp">
<rotate
android:fromDegrees="45"
android:toDegrees="45">
<shape android:shape="rectangle">
<solid android:color="#666666" />
<stroke android:color="#aaaaaa" android:width="1dp"/>
</shape>
</rotate>
</item>
<item android:width="30dp" android:height="10dp" android:bottom="21dp" android:gravity="center">
<shape android:shape="rectangle">
<solid android:color="#color/InputBg"/>
</shape>
</item>
</layer-list>
</item>
</layer-list>

Related Links

Android C++ and NOT C
Resize the EditText when softkeyboard gets displayed
How to get the location of user after getting longitude and latitude
Different possibilites for keeping wifi radio turned on?
How to retriving base64 strings(large image) from server to android
Why android:actionBarDivider doesn't work?
Progress Bar Not Updating on button click
xlarge vs sw720dp screen size confusion
how to load texture for meshes (not a3d object!) in renderscript?
Implementing Facebook App so that Android/iOS app can be easily generated [closed]
Adding android:configChanges to generated manifest
How do i setup android webdriver to work with selenium grid?
Is it possible to get a byte buffer directly from an audio asset in OpenSL ES (for Android)?
Grayscale PictureDrawable
How to get a textfield in android in this format?
Android app displaying a gif

Categories

HOME
fabricjs
awk
gpu
redux-form
phpmyadmin
jmx
sublimetext
soa
google-admin-sdk
nstableheaderview
title
rcloud
reactive-programming
mxgraph
jsonpath
intercom
symmetricds
internationalization
jquery-ias
dpdk
systemtime
event-store
qliksense
jboss6.x
ckfinder
jquery-multiselect
corpus
spotipy
uitapgesturerecognizer
dst
sammy.js
activexobject
slacktextviewcontroller
xajax
sharepoint-workflow
alphabetical
git-rewrite-history
release
odroid
ods
verifiable-c
spring-mvc-test
sharp-snmp
facebook-social-plugins
dapper-simplecrud
yii2-api
boxing
excel-dna
filehandle
renaming
docpad
simplepie
uicolor
clipboard.js
nss
dbamp
uiactionsheet
np-spring
dllimport
xvim
mod-proxy
exceldatareader
crowd
spring-remoting
paste
vbe
decoupling
http-patch
jammer
embedded-fonts
away3d
facebook-timeline
mantle
windows-98
robotlegs
patricia-trie
boost-msm
subproject
fusefabric
google-maps-mobile
twitterizer
globals
zend-rest
google-wave
cldc
alsb
change-management
mathematical-typesetting
pnrp

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