我在活动中查看了具有四个片段的寻呼机,每个片段的中心都有编辑文本,底部有按钮。但当 软键盘出现按钮没有相应调整,即。按钮不可见(它在键盘后面)。
我的代码:
main_activity.xml //activity layout
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/toolbar_main_screen"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
android:visibility="gone"
/>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/white"
android:fitsSystemWindows="true"
app:itemBackground="@drawable/nav_item_background"
app:itemTextAppearance="@style/NavDrawerTextStyle"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer_menu" />
</android.support.v4.widget.DrawerLayout>
first_fragment.xml //fragment_layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:fitsSystemWindows="true"
android:padding="40dp">
<LinearLayout
android:layout_alignParentBottom="true"
android:id="@+id/buttons"
android:background="#000000"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="#000000"
android:text="BACK"
android:visibility="invisible"
android:textColor="#ffffff" />
<Button
android:id="@+id/next_degree"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:background="@drawable/button_next"
android:text="Next"
android:layout_marginLeft="@dimen/size40dp"
android:textSize="@dimen/fontSize16sp"
android:textColor="@color/black" />
</LinearLayout>
<AutoCompleteTextView
android:layout_centerInParent="true"
android:imeOptions="actionDone"
android:maxLines="1"
android:layout_marginTop="@dimen/size8dp"
android:layout_width="match_parent"
android:id="@+id/degree"
android:backgroundTint="@color/black"
android:layout_height="wrap_content"
android:text="B.Tech"
android:textSize="@dimen/fontSize20sp"
android:textColor="@color/white"
android:textCursorDrawable="@drawable/color_cursor"
/>
<TextView
android:layout_above="@id/degree"
android:paddingLeft="4dp"
android:textColor="#999999"
android:text="Degree *"
android:textSize="@dimen/fontSize16sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
答案 0 :(得分:0)
根据我在上面的理解lolipop,我们必须添加以下属性来调整resize功能。
android:fitsSystemWindows="true"
请试一试。