Wednesday, May 8, 2013

[android-developers] LayoutInflater

So, I have this layout…  It starts out like this:


<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:layout_margin="35dp" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:shadowColor="#000"
            android:shadowDx="0"

When I do a setContentView with it, it is centered on the screen and looks as I want it to.

However, I am now placing a video behind it, so I'm using addContentView instead.  In order to use addContentView, I believe I need to use the LayoutInflater.  So, I'm doing this…

LayoutInflater inflater =  this.getLayoutInflater();
View v = inflater.inflate(R.layout.main2,null);

Anyhow, it is no longer centered.  It is left-justified.  Is there an easy way to center this again?

I have fiddled with this a lot, and it is getting frustrating.

Thanks.

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment