3

下から画面の約60%を占めるScrollViewを作成しようとしています。画面は横向きモードであり、scrollviewはこのアクティビティの唯一のビュー要素です。レイアウトマージンを強制することで800x480エミュレーター画面で動作させることができます(以下のXMLコードを参照)が、より高い解像度の画面に切り替えると、スクロールビューが画面の60%以上を占め、その結果、背景画像の情報。誰かがビューを画面サイズの約60%に保ち、できればさまざまな画面サイズを処理できるようにする方法についてアドバイスをいただけますか?

これが私のコードです:

<?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>
4

1 に答える 1

1
<?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>
于 2012-05-18T07:51:21.577 に答える