显示键盘时ConstraintLayout调整我的活动大小

时间:2018-07-23 10:18:47

标签: android android-constraintlayout

我是一个非常新的ConstraintLayout,我将此布局用作根视图组,并在设备edittext聚焦时刻运行我的设计,调整了设计视图的大小并折叠了它。我已经尽力了,需要指导。这是截图。请先帮助并表示感谢。

Samsung S6 Device 我在此设计中尝试了以下代码。请需要专家指导。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.constraint.Guideline
        android:id="@+id/gL_top"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.0" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_left_margin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_right_margin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintGuide_percent="1.0"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.35" />

    <android.support.constraint.ConstraintLayout
        android:id="@+id/cL_placeholder"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="8dp"
        android:background="@drawable/rect_shape_imageborder"
        app:layout_constraintBottom_toTopOf="@+id/gL_center"
        app:layout_constraintEnd_toStartOf="@+id/gL_right_margin"
        app:layout_constraintStart_toEndOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/gL_top">
    </android.support.constraint.ConstraintLayout>

    <android.support.constraint.Guideline
        android:id="@+id/gL_metadata_refernce_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.36" />

    <EditText
        android:id="@+id/edit_clipPrev_title"
        android:layout_width="match_parent"
        android:layout_height="33dp"
        android:layout_marginTop="8dp"
        android:gravity="center|start"
        android:imeOptions="actionDone"
        android:inputType="textCapSentences"
        android:maxLength="99"
        android:paddingEnd="5dp"
        android:paddingStart="5dp"
        android:singleLine="true"
        android:textColor="#ffffff"
        android:textSize="13sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/gL_metadata_refernce_title" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_metadata_refernce_privacy"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.46"
        app:layout_constraintTop_toBottomOf="@+id/edit_clipPrev_title" />

    <View
        android:id="@+id/view_privacy_1"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/menu_item_color"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/edit_clipPrev_title" />

    <TextView
        android:id="@+id/txtVw_clipPrev_privacy_title"
        android:layout_width="match_parent"
        android:layout_height="21dp"
        android:layout_marginTop="8dp"
        android:fontFamily="@string/roboto_regular"
        android:gravity="center|start"
        android:scrollbars="vertical"
        android:text="Privacy Settings *"
        android:textColor="#2cc455"
        android:textSize="13sp"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/gL_metadata_refernce_privacy" />

    <TextView
        android:id="@+id/txtVw_clipPrev_privacy"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginEnd="24dp"
        android:layout_marginTop="8dp"
        android:fontFamily="@string/roboto_regular"
        android:gravity="center|start"
        android:text="Privacy Settings *"
        android:textColor="#c2c2c2"
        android:textSize="10sp"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/txtVw_clipPrev_privacy_title" />

    <ImageView
        android:id="@+id/imgVw_clipPrev_privacy_cog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="19dp"
        android:src="@drawable/ic_right_arrow"
        app:layout_constraintEnd_toStartOf="@+id/gL_right_margin"
        app:layout_constraintTop_toTopOf="@+id/gL_metadata_refernce_privacy" />

    <View
        android:id="@+id/view_privacy_2"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="8dp"
        android:background="#c2c2c2"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/txtVw_clipPrev_privacy" />

    <android.support.constraint.Guideline
        android:id="@+id/gL_metadata_refernce_templates"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.5575" />

    <TextView
        android:id="@+id/txtVw_clipPrev_templates_title"
        android:layout_width="match_parent"
        android:layout_height="27dp"
        android:layout_marginTop="8dp"
        android:ellipsize="end"
        android:fontFamily="@string/roboto_regular"
        android:gravity="center|start"
        android:maxLines="1"
        android:paddingBottom="5dp"
        android:paddingEnd="25dp"
        android:paddingStart="0dp"
        android:paddingTop="0dp"
        android:text="Publish Template *"
        android:textColor="#2cc455"
        android:textSize="13sp"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/gL_metadata_refernce_templates" />

    <TextView
        android:id="@+id/txtVw_clipPrev_templates"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginTop="8dp"
        android:fontFamily="@string/roboto_regular"
        android:gravity="center|start"
        android:text="Publish Template *"
        android:textColor="#c2c2c2"
        android:textSize="10sp"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/txtVw_clipPrev_templates_title" />

    <ImageView
        android:id="@+id/imgVw_clipPrev_templates_cog"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="19dp"
        android:src="@drawable/ic_right_arrow"
        app:layout_constraintEnd_toStartOf="@+id/gL_right_margin"
        app:layout_constraintTop_toTopOf="@+id/gL_metadata_refernce_templates" />

    <View
        android:id="@+id/view_templates_1"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginTop="8dp"
        android:background="@color/menu_item_color"
        app:layout_constraintEnd_toEndOf="@+id/gL_right_margin"
        app:layout_constraintStart_toStartOf="@+id/gL_left_margin"
        app:layout_constraintTop_toBottomOf="@+id/txtVw_clipPrev_templates" />
</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案