2016-07-03 8 views
0

ポップアップ時にキーボードがレイアウトを隠すのを防ぐにはどうすればよいですか?私はこのコード行を使用して、キーボードが開いたときにレイアウトのサイズを変更します。キーボードがレイアウトコンポーネントを隠す

Window.SetSoftInputMode(SoftInput.AdjustResize); 

結果によっては、一部のデバイスの画面サイズが変更されても、他のデバイスに必要な範囲ではありません。

enter image description here

、ここで、それは別のデバイス上でどのように見えるかです:たとえば、ここでレイアウトが一つのデバイスに見えるものだあなたが見ることができるように、第2の画像で

enter image description here

、ログインボタンキーボードが重なっているために半分に見えます。また、上部の「ログイン」テキストが切り捨てられます。レイアウトをすべてのデバイスで同じに見えるようにするにはどうすればよいですか?

編集

私もこの行は私のMenifestファイルにしている:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:minWidth="25px" 
android:minHeight="25px" 
android:weightSum="100" 
android:id="@+id/signinwrapper" 
android:background="#F73494"> 
<LinearLayout 
    android:orientation="vertical" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:id="@+id/linearLayout2" 
    android:layout_weight="5" 
    android:gravity="center"> 
    <TextView 
     android:text="Login" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/textView1" 
     android:textAllCaps="true" 
     android:textColor="#FFFF" 
     android:textSize="14sp" /> 
</LinearLayout> 
<LinearLayout 
    android:paddingTop="20dp" 
    android:orientation="horizontal" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="40" 
    android:id="@+id/linearLayout1"> 
    <ImageView 
     android:src="@drawable/logo" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/imageView1" /> 
</LinearLayout> 
<LinearLayout 
    android:orientation="horizontal" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:id="@+id/linearLayout2" 
    android:layout_weight="15" 
    android:paddingTop="10dp"> 
    <TextView 
     android:text="Your home of Entertainment" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/textView1" 
     android:gravity="center" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     android:textAllCaps="true" 
     android:textColor="#FFFF" /> 
</LinearLayout> 
<LinearLayout 
    android:orientation="vertical" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:id="@+id/linearLayout3" 
    android:layout_weight="45"> 
    <EditText 
     android:id="@+id/username" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textEmailAddress" 
     android:hint="Username" 
     android:background="@drawable/editor" 
     android:layout_marginLeft="70dp" 
     android:layout_marginRight="70dp" 
     android:textSize="20dp" 
     android:gravity="center" 
     android:textStyle="bold" 
     android:textColor="#FFFF" /> 
    <EditText 
     android:id="@+id/password" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textPassword" 
     android:hint="Password" 
     android:background="@drawable/editor" 
     android:textSize="20dp" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="70dp" 
     android:layout_marginRight="70dp" 
     android:gravity="center" 
     android:textStyle="bold" 
     android:textColor="#FFFF" /> 
    <ProgressBar 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/progressBar" 
     android:layout_centerInParent="true" 
     android:layout_marginTop="20dp" 
     android:background="@drawable/ProgressBarStyle" 
     android:layout_gravity="center_horizontal" 
     android:visibility="gone" /> 
    <Button 
     android:text="Login" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/btnlogin" 
     android:layout_marginLeft="100dp" 
     android:layout_marginRight="100dp" 
     android:background="@drawable/buttonstyles" 
     android:textColor="#F73494" 
     android:layout_marginTop="20dp" 
     android:textSize="12sp" /> 
</LinearLayout> 

答えて

1

しないでください。

<activity android:name=".AccountActivity" android:label="yourtime" android:windowSoftInputMode="adjustResize|stateHidden"></activity> 

ここでレイアウト用のコードですそれはコードですそれをAndroidManifest xmlファイルで行います。特にダイアログがある場合は、コード内で奇妙な結果が得られます。

このモードを実行すると、キーボードの上に移動するようにアプリケーションのサイズを変更する必要があります。しかし、いくつかのものはちょうどスペースを取る。レイアウトのサイズを変更するのに十分な空白がある場合は、それが行われます。そうでなければ、キーボードはまだアプリケーションの一部をカバーします。あなたはあなたのレイアウトを投稿しなかったので、私はあなたにもっと詳細な答えを与えることはできません。

+0

元の質問を更新しました。見てください。 –

+0

あなたの重みは100に設定されていますが、すべての重みの合計は実際に105になります。一番上の線形レイアウトでweightsumを削除して、それが修正されているかどうかを確認します。問題があることに注意してください。「ログイン」という単語の最後がどのように途切れているかを見てください。単にそれ以上のスペースを与える以外にそれを修正する方法はありません。私が見ることができる唯一の方法は、あなたのイメージを小さくするかテキストサイズを小さくすることです、殺すべき垂直の空白がたくさんありません。 –

+0

ああ私はそれを認識しませんでした。テキストと画像をできる限り小さくしましたが、小さすぎると画面サイズの大きいデバイスでは小さすぎます。何かを妥協することなく、それらのコンポーネントすべてでそのレイアウトを実装する最良の方法は何ですか? Facebookのアプリは、キーボードがポップアップしたときにログインボタンの下のすべてを隠しますが、小さな画面の中のすべてを管理することもできます。私はレイアウトの問題を持つデバイスを持っていないので、テストする必要があります後であります。キーボードが開いているときに何かしらサイズを変更したり、表示したいものを制御していますか? –

関連する問題