gpt4 book ai didi

Android 布局边距不适用

转载 作者:行者123 更新时间:2023-11-30 03:21:56 25 4
gpt4 key购买 nike

在我的应用程序中,我完成了一个简单的注册 Activity ,我正在索尼 xperia neo(480x854 3.7"~265 ppi 运行 4.0 ics)和三星 gio(320x480 3.2"~180 ppi 运行 2.3. 6 姜 )
它在 xperia 上运行良好,但在三星上却不行(我猜布局边距不适用)
知道发生了什么事吗?

enter image description here enter image description here

这是我的xml文件

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<ImageView
android:id="@+id/main_img_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/bg" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="140dp"
android:orientation="vertical" >

<Spinner
android:id="@+id/reg_spinner_country"
android:layout_width="212dp"
android:layout_height="44dp"
android:layout_gravity="center"
android:background="@drawable/spinner_bg"
android:prompt="@string/country_prompt" />

<Spinner
android:id="@+id/reg_spinner_operator"
android:layout_width="212dp"
android:layout_height="44dp"
android:layout_gravity="center"
android:layout_marginTop="25dp"
android:background="@drawable/spinner_bg"
android:prompt="@string/operator_prompt" />

<LinearLayout
android:layout_width="212dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="25dp"
android:layout_weight="0"
android:background="@drawable/reg_layout_bg"
android:padding="3dp" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="33dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="@color/white"
android:padding="3dp" >

<TextView
android:id="@+id/reg_text_operator_key"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="+96279"
android:textColor="@color/black" />
</LinearLayout>

<EditText
android:id="@+id/reg_text_mobile_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:ems="7"
android:inputType="phone" >
</EditText>
</LinearLayout>

<ImageView
android:id="@+id/reg_but_submit"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/btn_register"
android:text="@string/submit_button" />
</LinearLayout>

</FrameLayout>

最佳答案

试试这个,我已经用相对布局试过了

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
android:id="@+id/main_img_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical" >

<Spinner
android:id="@+id/reg_spinner_country"
android:layout_width="212dp"
android:layout_height="44dp"
android:layout_gravity="center"
android:background="@drawable/spinner_bg"
android:prompt="@string/country_prompt" />

<Spinner
android:id="@+id/reg_spinner_operator"
android:layout_width="212dp"
android:layout_height="44dp"
android:layout_gravity="center"
android:layout_marginTop="25dp"
android:background="@drawable/spinner_bg"
android:prompt="@string/operator_prompt" />

<LinearLayout
android:layout_width="212dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="25dp"
android:layout_weight="0"
android:background="@drawable/reg_layout_bg"
android:padding="3dp" >

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="33dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="@color/white"
android:padding="3dp" >

<TextView
android:id="@+id/reg_text_operator_key"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="+96279"
android:textColor="@color/black" />
</LinearLayout>

<EditText
android:id="@+id/reg_text_mobile_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginRight="10dp"
android:layout_marginTop="3dp"
android:ems="7"
android:inputType="phone" >
</EditText>
</LinearLayout>

<ImageView
android:id="@+id/reg_but_submit"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:src="@drawable/btn_register"
android:text="@string/submit_button" />
</LinearLayout>

</RelativeLayout>

关于Android 布局边距不适用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18980670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com