2015-12-18 19 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>