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 SQLiteException
How to start activity from broadcast from Download manager?
How Can I create a tab inside another tab in Android?
Android Studio Push Commits - Add Remote
Android Studio 1.2.2 error on start: Unable to start the daemon process
Android TextureView / Drawing / Painting Performance
Screen record button is grayed out in Android Studio
Why my android GridView appear different from normal. It's covered by a holo blue block
Icons in TabLayout
Android Action Bar not showing
Error install ionic cordova
TextWatcher in Android
Fix textview at the top and button at the bottom of LinearyLayout
Scrollbar for multiple linear layout view in android
Start APP after Installation via android.provider.Telephony.SMS_RECEIVED [duplicate]
Changing language in run time with Preferences [android]

Categories

HOME
httparty
azure-stream-analytics
microsoftgraph
design-patterns
time-complexity
string
jmx
components
nsbundle
crystal-reports-2013
openstreetmap
drop-down-menu
octave
angular-dart
docx
esoteric-languages
standards
foreign-keys
gmm
articulate-storyline
roslyn
php-mysqlidb
flask-sqlalchemy
short-url
perlbrew
android-maps
sinch
jaws
complex-numbers
weather
cart
gnat-gps
classcastexception
sendbird
vue-chartjs
alphabetical
xcode7.3
opensmpp
apriori
android-softkeyboard
wmp
lpsolve
avcapturedevice
importerror
dapper-simplecrud
plan-9
fclose
geotiff
activeperl
pair-programming
subnet
type-theory
monkey
javafx-css
choice
slackware
file-uri
macaulay2
jquery-jscrollpane
avspeechsynthesizer
udpclient
freepbx
cfchart
kango-framework
stream-processing
data-protection
mobiledoc-kit
spring-retry
vhosts
django-urls
doctype
amiga
ocra
google-refine
mass-assignment
execve
post-commit-hook
sql-scripts
device-tree
insight.database
xml-namespaces
rcaller
video-codecs
jquery-blockui
extconf.rb
predicatebuilder
procedures
workflow-services
jqote
cloudfiles
diagrams
undefined-index
isapi-extension
application-verifier
burndowncharts
xslcompiledtransform

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App