Androidで奇妙な問題が発生しています。 ListViewの下にLinearLayoutがあります。リストビューの幅は0dp、layout_weightは90です。線形レイアウトlayout_weightは10、高さは0dpです。デバイスでは線形レイアウトが消えます。Androidのレイアウトは、デザイナーで正しくありますが、デバイスに間違いがあります。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView android:id="@+id/chatsListView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="90"
android:divider="@null"
android:dividerHeight="0dp"
android:listSelector="@android:color/transparent"
android:transcriptMode="alwaysScroll"
/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:padding="10dp">
<EditText
android:id="@+id/messageEditText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:inputType="textMultiLine"
android:hint="type message here"
android:ems="10"/>
<ImageButton
android:id="@+id/sendMessageButton"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@drawable/send_button"/>
</LinearLayout>
</LinearLayout>
私はそれが上記の問題であることを知る必要があります。私は別の方法でそれをしたくありません。私は論理的に学ぶためにこのプロジェクトをやっていて、ペーストをコピーしていません。デザイナーで
ここにプレビュー:
ここでのプレビューは、デバイスである:
私が開閉キーボードとき、それはデザイナーのようにサイズを変更します。コードにエラーがあるかどうかを知る必要があります。
編集:アンドロイド-devのIRCからZharfは、この解決策を見つけた:
Viewpager is being pushed out of the screen [CoordinatorLayout] [Design Library]
** PercentRelativeLayout **を使用しただけであれば、余分な不要なLinearLayoutを取り除くことができます。 –
外側の 'LinearLayout'に' android:weightSum = "100" 'を追加してみてください。 – Slav
「デザイナー」と「実際の」デバイスのデバイスから詳細を提供できますか?デバイスのサイズやデバイスそのもの(ネクサス、サムスンなど)のようなものです。 – hehe