8

いくつかのEditTextとロゴが画面の下部にボタンバーとともに表示されるログインビューを実装しようとしています。次のようになります。

代替テキストhttp://russellhaering.com/media/addAccount.png

問題は、非常に小さい画面では、特に横に回転させたときに、メインビュー全体が画面に収まらないことです。

私は現在持っています

<?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="#234C59"  >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingTop="5dip"
        android:paddingLeft="15dip"
        android:paddingRight="15dip"
        android:orientation="vertical" >
        <ImageView
            android:id="@+id/logo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitCenter"
            android:layout_centerHorizontal="true"
            android:src="@drawable/logo" />
        <EditText
            android:id="@+id/input_email"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:inputType="textEmailAddress"
            android:singleLine="true"
            android:hint="Username or email" />
        <EditText
            android:id="@+id/input_password"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop=""
            android:inputType="textPassword"
            android:singleLine="true"
            android:hint="Password" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/buttonbar_login"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="horizontal"
        style="@android:style/ButtonBar" >
        <Button
            android:id="@+id/button_signup"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Sign Up" />
        <Button
            android:id="@+id/button_login"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Log In" />
    </LinearLayout>
</RelativeLayout>

最初のLinnearLayoutを次のようなScrollViewにカプセル化してみました。

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
            <!-- Linear Layout Here -->
</ScrollView>

しかし、これには2つの問題があります。

  1. ScrollViewは、データがすべて収まらない画面でもスクロールしません

  2. ButtonBarはオンスクリーンキーボードの上に浮かんでおり、キーボードが上がったときに画面のさらに多くの部分を覆い隠します。

ScrollView内にボタンがあるとすべてがうまく機能しましたが、ButtonBarにボタンがあるので、これを理解するのに多くの問題があります。

4

2 に答える 2

15

ソリューションには2つのステップが必要であることが判明しました。

  1. スクロールできないのは、ScrollViewがボタンバーの後ろにあるためです。これを修正するために、ボタンバーの下にScrollViewを定義し、次にandroid:layout_above="@id/buttonbar_login"ScrollViewをボタンバーの上に完全に配置するために使用しました。

  2. どうやら、オンスクリーンキーボードを開くと、ScrollViewがある場合はサイズが変更され、ボタンバーがキーボードと一緒に浮き上がるようになります。これを修正するために、マニフェストを変更し、android:windowSoftInputMode = "adjustPan"を追加して、ScrollViewのサイズが変更されないようにしました。

于 2010-08-03T05:36:25.647 に答える
0

ユースケースで横向きのボタンバーの非表示がサポートされている場合は、ボタンバーを確認Resources.getSystem().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPEしてに設定できますView.GONE

また、マニフェストファイルでを設定する必要がありandroid:windowSoftInputMode="adjustResize"ます。<activity>AndroidはadjustResize、ルートレイアウトがScrollView(iirc)の場合にのみ自動的に配置します。

于 2010-08-03T03:57:05.010 に答える