0

I have the following layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
    android:id="@+id/app_name"
    android:text="@string/app_name"
    android:layout_centerHorizontal="true"
    android:textSize="30sp"
    android:textColor="#FF000000"
    android:singleLine="true"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="30dp"
    android:layout_marginRight="30dp"
    android:layout_alignParentTop="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />
</RelativeLayout>

I expected the layout to extend to the edges of the screen, but instead here's what I get:

enter image description here

The declared theme is Theme.K9Dialog:

<resources>
<style name="Theme.K9Dialog" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowBackground">@drawable/popup_background</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowContentOverlay">@drawable/panel_separator</item>
</style>

Am I misunderstanding what android:layout_width is supposed to do?

FractalBob
  • 3,225
  • 4
  • 29
  • 40

1 Answers1

0

This is happening because of <item name="android:windowIsFloating">true</item> in your app theme, should work fine after removing that. Also I am not why you need all those attributes like android:windowFrame and ndroid:windowAnimationStyle in your app theme. If there is no such requirement try using default app theme and add only those attributes to theme which you want to change .