Ich habe einen ganzen Tag verbringen Forschung darüber, wie dies zu erreichen. Ich habe einen Scrollview, einen Editiertext darunter und einen Button rechts neben dem Editiertext.Android Scroll Layout nach oben, wenn die Tastatur auf dem Bildschirm erscheint
1) Ich versuche, alle diese Inhalte nach oben zu bewegen, da die Tastatur erscheint, ohne dass sich die Ansichten überschneiden.
Ich habe verschiedene Lösungen ausprobiert wie Marge, Polsterung, windowsoftinputMode, mein Layout auf verschiedene Weise zu ändern, aber ich konnte das nicht noch erreichen. Bitte hilf mir! Dies ist mein Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/detailsToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorToolbar"
android:elevation="4dp"
android:theme="@style/Toolbar_iconTheme" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/detailsToolbar"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/displayPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="100dp"
android:maxWidth="80dp"
android:minHeight="80dp"
android:minWidth="70dp"
android:padding="4dp"
android:src="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@+id/displayPicture"
android:paddingLeft="4dp"
android:paddingTop="4dp"
android:text="ProfileName"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
android:textColorHighlight="@android:color/holo_blue_dark"
android:textSize="16sp" />
<TextView
android:id="@+id/post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_toRightOf="@+id/displayPicture"
android:padding="4dp" />
<TextView
android:id="@+id/commentsline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/displayPicture"
android:background="@android:color/darker_gray"
android:padding="4dp"
android:text="comments"
android:textAlignment="center" />
<android.support.v7.widget.RecyclerView
android:id="@+id/commentsListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/commentsline" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/messageText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="32dp"
android:background="@drawable/rounded_corners"
android:scrollbars="vertical" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@android:drawable/ic_menu_send" />
</RelativeLayout>
</LinearLayout>
und Manifest:
<activity
android:name=".DetailsActivity"
android:windowSoftInputMode="adjustResize"/>
Sie müssen Ihr gesamtes Layout in einen "Container" einfügen, wie wenn Sie eine Snackbar-Benachrichtigung hinzufügen. Wenn Sie eine Snackbar-Benachrichtigung hinzufügen, müssen Sie einen Container angeben und Elemente platzieren, die die Snackbar nach oben verschieben soll, wenn sie im Container angezeigt wird. Dies geschieht mit einem Coordinator-Layout (alias FrameLayout). Snackbar: https://developer.android.com/training/snackbar/showing.html Eine weitere Quelle für Ihre Fragen scheinen die Leute zu mögen: https://stackoverflow.com/a/1964928/4167644 – Frank
nur versuchen Sie ' ' –
https://Stackoverflow.com/questions/16411056/how-to-adjust-layout-when-soft- Tastatur erscheint, Dies ist die beste Lösung für dieses Problem. hoffe, es hilft dir bei deinen Sachen. – InsaneCat