デザイナーのサーフェスに新しいコンテナビューを追加し、layout:width
とlayout:height
をwrap_content
に設定すると、コンテナの表示サイズが以下のようになります。コンテナがAndroidスタジオのプレビューを超えて伸びる
この問題を解決するにはどうすればよいですか? content_main.xml
EDITの
コードスニペットは:上記画像それでも同じ問題から少し異なる場合がございます。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.dance2die.myapplication.MainActivity"
tools:showIn="@layout/activity_main">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:padding="0dp" />
</RelativeLayout>
これは、リストビューでアイテムの高さと幅を計算する前に、リストビューにリストビューアイテムを設定する必要があるためです。したがって、測定された高さと幅がなければ、必要なときにコンテンツをラップすることはできません。リストビューにxmlのサンプルコンテンツを取り込む以外に、これを修正する良い方法はないと思います。 –
イメージで提供するのではなく、XMLコードスニペットを投稿してください。 –