我在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