san*_*one 2 android android-layout android-linearlayout
这是基本的XML文件
<?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:orientation="vertical"
android:background="@color/white"
>
<!--top part-->
<include layout="@layout/top" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="1"/>
<!--content area-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="#ff6600"
>
</LinearLayout>
<!--bottom part-->
<include layout="@layout/bottom" android:layout_width="fill_parent"
android:layout_height="0dp" android:layout_weight="1"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当我在模拟器中加载它时,它看起来像在下面的图像.

我究竟做错了什么?
编辑
这是顶部和底部的XML.基本也是.
<?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"
>
<ImageView
android:id="@+id/bottom_image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/bottom"
/>
</LinearLayout>
-----------------------------------------------------------
<?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"
>
<ImageView
android:id="@+id/top_image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/top"
/>
Run Code Online (Sandbox Code Playgroud)
请尝试以下
Top.xml
<?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="wrap_content"
android:id="@+id/top"
>
<ImageView
android:id="@+id/top_image"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/top"
android:scaleType="fitXY"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
Bottom.xml
<?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="wrap_content"
android:id="@+id/bottom"
>
<ImageView
android:id="@+id/bottom_image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/bottom"
android:scaleType="fitXY"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
最后是Main.xml
<?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:orientation="vertical"
android:background="#000000"
>
<!--top part-->
<include layout="@layout/top" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<!--content area-->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ff6600"
>
</LinearLayout>
<!--bottom part-->
<include layout="@layout/bottom" android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这将解决您的问题
| 归档时间: |
|
| 查看次数: |
3000 次 |
| 最近记录: |