user1834464
user1834464

Reputation:

TextView "fill_parent" does not fill the parent

I have a simple layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

But my TextView is not taking all of the width even though I did fill_parent. How can I make it's with full size instead of just the size of the content?

Upvotes: 5

Views: 7414

Answers (1)

Shobhit Puri
Shobhit Puri

Reputation: 26007

Make the outer LinearLayout to have match_parent instead of wrap_content in the attributes android:layout_width and android:layout_height .

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

Upvotes: 7

Related Questions