我在Android中遇到了XML问题。在图形布局视图中,它看起来完全是我想要的,但是当我在10.1英寸的屏幕上运行模拟时,它与父宽度相匹配但不是高度。当我在10.1英寸平板电脑上运行模拟时,宽度或高度。这是我的代码,Android relativeLayout在模拟中不匹配父级,但是在图形视图中
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:background="#fff">
<!-- Header Starts-->
<LinearLayout android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@layout/header_gradient"
android:paddingTop="5dip"
android:paddingBottom="5dip">
<!-- Logo Start-->
<ImageView android:src="@drawable/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"/>
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="90dip"
android:background="@layout/footer_repeat"
android:layout_alignParentBottom="true">
</LinearLayout>
<!-- Footer Ends -->
<!-- Registration Form -->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="@id/header">
<!-- Full Name Label -->
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Full Name"/>
<EditText android:id="@+id/reg_fullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:layout_marginBottom="20dip"/>
<!-- Email Label -->
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Email"/>
<EditText android:id="@+id/reg_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:layout_marginBottom="20dip"/>
<!-- Password Label -->
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Password"/>
<EditText android:id="@+id/reg_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:password="true"
android:singleLine="true"
android:layout_marginTop="5dip"/>
<!-- Register Button -->
<Button android:id="@+id/btnRegister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Register New Account"/>
<!-- Link to Login Screen -->
<TextView android:id="@+id/link_to_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:layout_marginBottom="40dip"
android:text="Have an account? Login here"
android:gravity="center"
android:textSize="20dip"
android:textColor="#025f7c"/>
</LinearLayout>
<!-- Registration Form Ends -->
</RelativeLayout>
</ScrollView>
这是它是如何在图形布局所示,是我多么希望它看起来,
这是它的外观在Android的虚拟机3.2模拟,
最后,这是它的外观在我的三星Galaxy 10.1" 平板电脑,
任何人都可以看到我在哪里呢?谢谢
尝试:在你的'manifest'中使用'android:targetSdkVersion =“11”' – 2012-08-05 16:26:39