Android: Help with two linear layout that overlaps each other!
I would like to have two linear layouts inside a third parent layout. I would like the first linear layout ori开发者_Python百科entation to be horizontal and the second one to be vertical.
I tried to achieve this by the following code. However, the second linear layout do not appear.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_horizontal"
>
<ImageButton android:id="@+id/ImageButton01"
android:layout_width="80px"
android:layout_height="80px"
android:background="@drawable/projects_badge"
android:layout_margin="10px"/>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal"
>
<ImageView android:id="@+id/ImageView01"
android:layout_width="200px"
android:layout_height="81px"
android:src="@drawable/logo"
android:adjustViewBounds="true"
android:layout_marginTop="15px"/>
<TextView android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textColor="#9CC721"/>
</LinearLayout>
</LinearLayout>
Any help will be appreciated.
Thanks in advance.
I think you need to specify android:orientation
attribute inside the Parent Layout as well.
Tips:
dp
and dip
are more preferrable than px.
Update:
your parent layout should be like:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical">
your image view in 2nd sub-layout should be like:
<ImageView android:id="@+id/ImageView01"
android:layout_width="200px"
android:layout_height="81px"
android:src="@drawable/logo"
android:adjustViewBounds="true"
android:layout_marginTop="15px"
android:scaleType="center"/>
精彩评论