How to configure ScrollView to fit 60% of the screen from the bottom?

I am trying to create a ScrollView that takes up about 60% of the screen from the bottom. The screen is in landscape mode, and scrollview is the only element of the view in this action. I can make it work on the screen of the 800x480 emulator, forcing layout layouts (see the XML code below), but when I switch to a higher resolution screen, scrollview will occupy more than 60% of the screen and as a result it covers some of the information background image. Can someone ask for advice on how to keep the view at about 60% of the screen size and possibly be able to handle different screen sizes?

Here is my code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/safety_base"
    android:orientation="vertical"
    android:padding="0dp" >

    <ScrollView
        android:id="@+id/scrollSafety"
        android:layout_width="435dp"
        android:layout_marginBottom="10dp" 
        android:layout_marginTop="120dp"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:scrollbars="none" >

        <RelativeLayout
            android:id="@+id/layoutSafety"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <ImageView
                android:id="@+id/imgSafety"
                android:contentDescription="@string/imgSafety_desc"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:src="@drawable/safety_info" />

        </RelativeLayout>

    </ScrollView>

</RelativeLayout>
+3
source share
1 answer
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"

android:orientation="vertical"
android:padding="0dp" >

<ScrollView
    android:id="@+id/scrollSafety"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="3"
    android:background="@android:color/background_light"
    android:scrollbars="none" >

    <RelativeLayout
        android:id="@+id/layoutSafety"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <ImageView
            android:id="@+id/imgSafety"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:contentDescription="Blah blah"
            android:src="@drawable/icon" />
    </RelativeLayout>
</ScrollView>

<FrameLayout 
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="2"
    android:visibility="invisible"
    />
</LinearLayout>
+1
source

All Articles