#android #android-layout
#Android #android-layout
Вопрос:
Я создал макет с графическим макетом в Eclipse,
Что я вижу в Eclipse
.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="1">
<RelativeLayout android:id="@ id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent">
<AutoCompleteTextView android:layout_height="wrap_content" android:id="@ id/autoCompleteTextView1" android:layout_width="fill_parent" android:layout_below="@ id/textView1" android:layout_alignParentLeft="true" android:text="@string/emptyString"></AutoCompleteTextView>
<TextView android:layout_height="wrap_content" android:textSize="20sp" android:id="@ id/textView1" android:layout_width="wrap_content" android:text="@string/toString" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"></TextView>
<LinearLayout android:id="@ id/linearLayout1" android:layout_height="wrap_content" android:layout_below="@ id/autoCompleteTextView1" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_width="fill_parent">
<Button android:layout_height="wrap_content" android:layout_weight="0.33333333" android:id="@ id/buttonContacts" android:text="@string/contactsString" android:textSize="17sp" android:layout_width="fill_parent"></Button>
<Button android:layout_height="wrap_content" android:layout_weight="0.33333333" android:id="@ id/buttonGroups" android:text="@string/groupsString" android:textSize="17sp" android:layout_width="fill_parent"></Button>
<Button android:text="@string/favouritesString" android:layout_height="wrap_content" android:id="@ id/buttonFavourites" android:layout_weight="0.33333333" android:textSize="17sp" android:layout_width="fill_parent"></Button>
</LinearLayout>
<TextView android:layout_height="wrap_content" android:textSize="20sp" android:id="@ id/textView3" android:layout_width="fill_parent" android:text="@string/repetition" android:layout_below="@ id/editText1" android:layout_alignParentLeft="true"></TextView>
<Spinner android:layout_width="fill_parent" android:id="@ id/spinner" android:layout_height="wrap_content" android:prompt="@string/repetition" android:layout_below="@ id/textView3" android:layout_alignParentLeft="true"></Spinner>
<LinearLayout android:layout_width="wrap_content" android:id="@ id/linearLayout2" android:layout_height="wrap_content" android:layout_alignTop="@ id/button1" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentBottom="true">
<Button android:layout_height="wrap_content" android:id="@ id/button2" android:textSize="17sp" android:layout_width="fill_parent" android:layout_weight="0.50" android:text="@string/button_ok"></Button>
<Button android:layout_height="wrap_content" android:id="@ id/button1" android:textSize="17sp" android:layout_weight="0.5" android:layout_width="fill_parent" android:text="@string/button_cancel"></Button>
</LinearLayout>
<TextView android:layout_height="wrap_content" android:textSize="20sp" android:id="@ id/textView2" android:layout_width="fill_parent" android:text="@string/messageString" android:layout_below="@ id/linearLayout1" android:layout_alignParentLeft="true"></TextView>
<ImageButton android:layout_width="wrap_content" android:src="@drawable/button_time" android:layout_height="wrap_content" android:background="@drawable/background_black" android:id="@ id/imageButton1" android:layout_below="@ id/spinner" android:layout_toRightOf="@ id/textView1"></ImageButton>
<ImageButton android:layout_width="wrap_content" android:src="@drawable/button_date" android:layout_height="wrap_content" android:background="@drawable/background_black" android:id="@ id/imageButton2" android:layout_alignTop="@ id/imageButton1" android:layout_alignParentRight="true" android:layout_marginRight="60dp"></ImageButton>
<EditText android:id="@ id/editText1" android:layout_below="@ id/textView2" android:layout_alignParentLeft="true" android:layout_width="fill_parent" android:gravity="top|left" android:layout_height="110dp">
<requestFocus></requestFocus>
</EditText>
</RelativeLayout>
</LinearLayout>
вот как я вижу это в эмуляторе при запуске приложения
вот как я вижу это в эмуляторе после изменения того, что я выбираю в списке
Есть идеи, что здесь не так?
Ответ №1:
Когда вы ссылаетесь на id, там не должно быть » «. Это плохо:
android:layout_below="@ id/editText1"
Это хорошо:
android:layout_below="@id/editText1"
Используйте «@ id / …» только в определении элемента.
Комментарии:
1. Только что создал макет, не получил возможности отредактировать идентификаторы. но я не думаю, что это проблема…
2. ADT — не самый стабильный инструмент. Обычно вам приходится редактировать XML-файлы самостоятельно.