Похоже на создание макета XML для телефонов. Возможно, я был слишком длинным с Xcode или просто не понимаю, как это сделать на Android.Плагин для студии Android для телефонов
Я играл с созданием макетов для размера (маленький, обычный, большой, большой) и плотности, но ничего не работает.
У меня есть фон для моего экрана, прикрепленный, и мне нравится позиционировать два поля ввода и кнопку над макетом. Это работает отлично, используя относительную компоновку. Но при работе на устройствах, реальных или симуляторах, поля никогда не будут правы над фоном. Что я делаю не так?
XML, для нормального расположения:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView3"
android:src="@drawable/login2"
android:scaleType="fitXY" />
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/tfPass"
android:hint="CONTRASEÑA"
android:inputType="textPassword"
android:textColor="#000000"
android:background="#00000000"
android:singleLine="true"
android:layout_weight="1"
android:layout_x="3dp"
android:layout_y="342dp"
android:layout_alignTop="@+id/tfMail"
android:layout_marginTop="76dp"
android:layout_alignLeft="@+id/tfMail"
android:layout_alignStart="@+id/tfMail"
android:layout_alignRight="@+id/tfMail"
android:layout_alignEnd="@+id/tfMail" />
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/tfMail"
android:hint="EMAIL large"
android:textColor="#000000"
android:background="#00000000"
android:singleLine="true"
android:inputType="textEmailAddress"
android:layout_weight="1"
android:layout_x="3dp"
android:layout_y="287dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="353dp"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp" />
<ImageButton
android:layout_width="250dp"
android:layout_height="50dp"
android:id="@+id/btnLogin"
android:background="#00000000"
android:onClick="sel_Login2_login"
android:layout_weight="1"
android:layout_x="2dp"
android:layout_y="413dp"
android:layout_below="@+id/tfPass"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp" />
</RelativeLayout>
предварительный просмотр witout панели действий и в полноэкранном режиме. Кроме того, это я имею в манифесте деятельности:
<activity
android:name=".Login2View"
android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
и, наконец, фон
ОБНОВЛЕНИЕ - полный макет XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login2">
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/tfPass"
android:hint="CONTRASEÑA"
android:inputType="textPassword"
android:textColor="#000000"
android:background="#00000000"
android:singleLine="true"
android:layout_weight="1"
android:layout_x="3dp"
android:layout_y="342dp"
android:layout_alignTop="@+id/tfMail"
android:layout_marginTop="55dp"
android:layout_alignLeft="@+id/tfMail"
android:layout_alignStart="@+id/tfMail"
android:layout_alignRight="@+id/tfMail"
android:layout_alignEnd="@+id/tfMail" />
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="@+id/tfMail"
android:hint="EMAIL normal"
android:textColor="#000000"
android:background="#00000000"
android:singleLine="true"
android:inputType="textEmailAddress"
android:layout_weight="1"
android:layout_x="3dp"
android:layout_y="287dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="255dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp" />
<ImageButton
android:layout_width="215dp"
android:layout_height="50dp"
android:id="@+id/btnLogin"
android:background="#00000000"
android:onClick="sel_Login2_login"
android:layout_weight="1"
android:layout_x="2dp"
android:layout_y="413dp"
android:layout_below="@+id/tfPass"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" />
</RelativeLayout>
UPDATE 03.11.2015
Я приложу скриншот от Android Studio. При использовании одного и того же формата XML на разных устройствах EditText и Button теряются. Я поместил другой цвет фона для каждого. Это результат, как показано в Android Studio и она выглядит так же на устройствах:
Какова ваша предыстория? "imageView3" с @ drawable/login2? – LaurentY
Да, это правильно –
Почему вы не применяете фон к корневому расположению – Prakhar