Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Containers stretch beyond in Android Studio preview

Whenever I add a new container view on the designer surface and sets both layout:width and layout:height to wrap_content, the container view size goes beyond what it should be as shown below.

What should I do to fix this issue?

Android Studio

Code snippet of content_main.xml

enter image description here

EDIT: Might be a bit different from image above but still the same issue.

<?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>
like image 649
dance2die Avatar asked Apr 14 '16 00:04

dance2die


1 Answers

Use

android:layout_width="match_parent" android:layout_height="match_parent"

like image 160
Samira Avatar answered Sep 22 '22 23:09

Samira