2017-11-30 13 views
0

私は背景イメージを持つ親レイアウトを持っているので、キーボードがポップアップしたときにスクロールビューを追加すると、背景イメージが縮小します。キーボードポップアップで背景イメージが縮む

画像以下のように:私は、SO上のすべてのソリューションを確認adjustResizeとadjustPanとしてwindowSofInputを追加することが、adjustResize dosentは、問題を解決し、adjustPanを使用してページをスクロールアップカント

enter image description here

enter image description here

、スクロール表示dosent調整パンで動作します。

fillViewPort、adjustViewBoundsなどのスクロールビューの属性をいくつか追加しようとしました。

また、 を試してみました このスクロールビューでは縮小されませんが、フルスクリーンは必要ありません。ステータスバーはフルスクリーンで表示されません。

バックグラウンドイメージを親レイアウトに設定するのではなく、イメージビューを追加しようとしましたが、scaleTypeを設定しようとしましたが、行列スケールタイプの線量は縮小しますが、バックグラウンドイメージは元のイメージとは異なります。

それはtihsのようになります。

enter image description here

enter image description here

レイアウトファイル

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 

    tools:context="com.example.admin.SmartCabFuelCard.RegisterDriver"> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:scaleType="matrix" 
     android:src="@drawable/page"/> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/bg_color" 
     android:alpha="0.5"/> 

    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:adjustViewBounds = "true" 
     android:isScrollContainer="true" 
     android:fillViewport="true"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     tools:context="com.example.admin.SmartCabFuelCard.RegisterDriver"><!-- 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/page" 
     android:scaleType="fitXY"/> 
--> 


     <RelativeLayout 
      android:id="@+id/rl" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_centerHorizontal="true" 
      android:layout_marginEnd="@dimen/dimen_10dp" 
      android:layout_marginStart="@dimen/dimen_10dp" 
      android:layout_marginLeft="@dimen/dimen_10dp" 
      android:layout_marginRight="@dimen/dimen_10dp"> 

      <ImageView 
       android:id="@+id/logo" 
       android:layout_width="100dp" 
       android:layout_height="100dp" 
       android:layout_alignParentTop="true" 
       android:layout_centerHorizontal="true" 
       android:layout_marginTop="@dimen/dimen_20dp" 
       android:src="@drawable/petrolpump" /> 

      <TextView 
       android:id="@+id/register_driver_welcome" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentEnd="true" 
       android:layout_below="@+id/logo" 
       android:layout_marginTop="@dimen/dimen_15dp" 
       android:padding="@dimen/dimen_10dp" 
       android:text="@string/welcome_driver" 
       android:textColor="@color/divider_color" 
       android:textStyle="bold" /> 

      <EditText 
       android:id="@+id/edt_mobile" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/register_driver_welcome" 
       android:drawableLeft="@drawable/ic_local_phone" 
       android:hint="Mobile No." 
       android:inputType="number" 
       android:maxLength="10" 
       android:maxLines="1" 
       android:padding="@dimen/dimen_15dp" 
       android:textColor="@color/divider_color" 
       android:textColorHint="@color/hint_color" 
       android:textSize="@dimen/dimen_15dp" /> 

      <TextView 
       android:id="@+id/register_driver_enter" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentEnd="true" 
       android:layout_below="@+id/edt_mobile" 
       android:padding="@dimen/dimen_10dp" 
       android:text="@string/otp_send" 
       android:textColor="@color/divider_color" 
       android:textStyle="bold" /> 

      <EditText 
       android:id="@+id/register_driver_otp" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/register_driver_enter" 
       android:layout_centerHorizontal="true" 
       android:layout_gravity="center" 
       android:layout_marginTop="@dimen/dimen_5dp" 
       android:drawableLeft="@drawable/ic_lock_close" 
       android:hint="OTP" 
       android:inputType="number" 
       android:maxLength="4" 
       android:maxLines="1" 
       android:padding="@dimen/dimen_15dp" 
       android:textColor="@color/divider_color" 
       android:textColorHint="@color/hint_color" 
       android:textSize="@dimen/dimen_15dp" /> 


      <Button 
       android:id="@+id/register_driver_register" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/register_driver_otp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginBottom="@dimen/dimen_20dp" 
       android:layout_marginTop="20dp" 
       android:background="@color/colorPrimary" 
       android:text="Register" 
       android:textColor="@android:color/white" /> 

      <Button 
       android:id="@+id/register_driver_sendotp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/edt_mobile" 
       android:layout_centerHorizontal="true" 
       android:layout_marginBottom="@dimen/dimen_40dp" 
       android:layout_marginTop="20dp" 
       android:background="@color/colorPrimary" 
       android:text="Send OTP" 
       android:textColor="@android:color/white" /> 

      <Button 
       android:id="@+id/btn_resend" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignStart="@+id/register_driver_register" 
       android:layout_below="@+id/register_driver_otp" 
       android:layout_centerHorizontal="true" 
       android:layout_marginBottom="@dimen/dimen_20dp" 
       android:layout_marginTop="20dp" 
       android:background="@color/colorPrimary" 
       android:text="RESEND OTP" 
       android:textColor="@android:color/white" 
       android:visibility="gone" /> 
     </RelativeLayout> 
    </RelativeLayout> 
    </ScrollView> 
</RelativeLayout> 

誰もがこれで私を助けてくださいことはできますか?ありがとうございました。

+0

あなたのレイアウトXML – Naz141

+0

はい多分このことができますNaz141 – Sid

+0

@確認してくださいコメントを追加投稿してください:https://stackoverflow.com/questions/16135984/full-screen-background-image-in-an-activity(使用最初にイメージビューを追加してください。)また、別の相対レイアウト(スクロールビュー - >相対レイアウト - >相対レイアウト)内に相対レイアウトをネストする理由はありますか? –

答えて

0

xmlに背景を設定しないでください。画像をウィンドウの背景として設定します。

getWindow().setBackgroundDrawableResource(R.drawable.bg); 

とマニフェストエントリ

<activity 
     android:name=".ActivityName" 
     android:configChanges="screenSize|keyboard|orientation|screenSize" 
     android:screenOrientation="portrait" 
     android:theme="@style/AppTheme.NoActionBar" 
     android:windowSoftInputMode="stateHidden" /> 
+0

これは動作していますが、ウィンドウの画面に設定されているので、一部の画像はAppbarの下に隠れています。 @ADM – Sid

+0

設定変更のために動作していますか?\ – Sid

+0

これはウィンドウに設定されているためです。 AppBarを使用している場合は、マニフェストでandroid:windowSoftInputMode = "adjustNothing"を使用して、ルートでxmlのLinearlayoutを使用することができます。添付した画像にAppBarが表示されないため、このソリューションを送信しました。 – ADM

-1

あなたが背景画像を設定したい場合は、代わりにImageViewのを使用してのあなたの親relativelayoutでそれを設定する必要があります。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@drawable/page" 
tools:context="com.example.admin.SmartCabFuelCard.RegisterDriver"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/bg_color" 
    android:alpha="0.5"/> 

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:adjustViewBounds = "true" 
    android:isScrollContainer="true" 
    android:fillViewport="true"> 

..... 
関連する問題