In my main.xml layout_gravity works normally with LinearLayout and
when you use setContentView(R.layout.main);
But if I inflate this xml file and then add it on screen using
addContentView or addView layout_gravity stops work - content of
main.xml draw in top position of screen.
Here is the code:
public class LayoutDoubleInflatingTest extends Activity {
LinearLayout ll;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RelativeLayout rl = (RelativeLayout)
findViewById(R.id.main_rl);
LayoutInflater inflanter = getLayoutInflater();
ll = (LinearLayout) inflanter.inflate(R.layout.test1, null,
false);
LayoutParams param = new
LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
rl.addView(ll, param);
}
}
main.xml source:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/main_rl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
android:gravity="right"
/>
</RelativeLayout>
test1.xml source:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/ttt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AAAAAAAAAA"
/>
</RelativeLayout>
</LinearLayout>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en