2015-12-18 71 views
0

我正試圖在軟鍵盤加載時調整我的屏幕。正常的屏幕看起來像這樣。 enter image description here軟鍵盤發行

但是,當用戶單擊EditText時,視圖會中斷並出現如下所示。在我的清單的活動我加入以下機器人:windowSoftInputMode =「adjustResize」 enter image description here

我想什麼發生的是,無論是在底部的按鈕出現,且整個EDITTEXT沒有被切割可見當用戶點擊EditText時。

編輯:將以下行添加到我的活動getWindow()。setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);使我的視圖看起來像這樣。但我還是希望我的兩個按鈕出現在EditText上 enter image description here

XML爲底部的EditText底部和按鈕

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1.6 " 
     android:background="#FFFFFF" 
     android:orientation="vertical"> 

     <LinearLayout 

      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1"> 

      <EditText 

       android:hint="Enter your Message" 
       android:ems="10" 
       android:id="@+id/messageET" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_weight="1"> 

       <RelativeLayout 
        android:background="@drawable/lightrectangle" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="2.5"> 

        <ImageButton 
         android:id="@+id/addimgbtn" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerVertical="true" 
         android:background="#f6f6f6" 
         android:paddingLeft="10dp" 
         android:src="@mipmap/blueadd" /> 

        <TextView 
         android:paddingLeft="10dp" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="?android:attr/textAppearanceSmall" 
         android:text="Add an image" 
         android:id="@+id/textView4" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+id/addimgbtn" 
         /> 
       </RelativeLayout> 


       <RelativeLayout 
        android:background="@drawable/lightrectangle" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="2.5"> 

        <ImageButton 
         android:id="@+id/sendbtn" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerVertical="true" 
         android:paddingLeft="10dp" 
         android:layout_weight="2.5" 
         android:background="#f6f6f6" 
         android:src="@mipmap/bluesend" /> 

        <TextView 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:textAppearance="?android:attr/textAppearanceSmall" 
         android:text="Send Message" 
         android:id="@+id/sendmsgTV" 
         android:layout_centerVertical="true" 
         android:layout_toRightOf="@+id/sendbtn" 
         android:paddingLeft="10dp" 
         /> 
       </RelativeLayout> 
      </LinearLayout> 
    </LinearLayout> 
+0

你將有權發佈至少佈局的一個簡化版本。調整大小是你想要的,但需要有一個實際上可以調整大小的視圖。 –

+0

@GabeSechan我需要調整什麼? – revipod

+0

該中央清單需要收縮。 –

回答

1

添加一個字段或佈局滾動視圖這將汽車內部調整你的佈局。你可以滾動你的佈局,它可以在所有屏幕上自動調節。

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1.6 " 
android:background="#FFFFFF" 
android:orientation="vertical" > 

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" > 

     <EditText 
      android:id="@+id/messageET" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:ems="10" 
      android:hint="Enter your Message" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" > 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="2.5" 
      android:background="@drawable/lightrectangle" > 

      <ImageButton 
       android:id="@+id/addimgbtn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:background="#f6f6f6" 
       android:paddingLeft="10dp" 
       android:src="@mipmap/blueadd" /> 

      <TextView 
       android:id="@+id/textView4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toRightOf="@+id/addimgbtn" 
       android:paddingLeft="10dp" 
       android:text="Add an image" 
       android:textAppearance="?android:attr/textAppearanceSmall" /> 
     </RelativeLayout> 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="2.5" 
      android:background="@drawable/lightrectangle" > 

      <ImageButton 
       android:id="@+id/sendbtn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_weight="2.5" 
       android:background="#f6f6f6" 
       android:paddingLeft="10dp" 
       android:src="@mipmap/bluesend" /> 

      <TextView 
       android:id="@+id/sendmsgTV" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:layout_toRightOf="@+id/sendbtn" 
       android:paddingLeft="10dp" 
       android:text="Send Message" 
       android:textAppearance="?android:attr/textAppearanceSmall" /> 
     </RelativeLayout> 
    </LinearLayout> 
</ScrollView>