I am making the layout and using the layout_weight and weight_sum. I am making the orientation of linear layout to horizontal so i am able to set the width of imageview 1/3 of the screen. But I dont know how to set the height of imageview to 1/3 of the screen.
Please help me to set the imageview height to 1/3 of the screen from the layout xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" 
    android:weightSum="1">
    <ImageView
    android:id="@+id/savedImageView"
    android:layout_width="0dip"
    android:layout_height="wrap_content"
    android:layout_weight=".33"
    android:background="@drawable/background" />
</LinearLayout>
Thanks in advance
Use this:
int displayWidth = getWindowManager().getDefaultDisplay().getHeight();
ImageView imageView = (ImageView)findViewById(R.id.image);
imageView.getLayoutParams().height = displayWidth / 3;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With