#mono #xamarin #xamarin.android #xamarin-studio
#моно #xamarin #xamarin.android #xamarin-studio
Вопрос:
Я хочу добавить btton (button1) в нижней части экрана, который будет отображаться всегда., независимо от количества данных внутри scrollview. Моя кнопка1 не отображается в нижней части экрана. Кто-нибудь знает, где я ошибаюсь?
<?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:background="#ffffffff">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:text="Step 1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@ id/step1TextView"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textStyle="normal"
android:textColor="#ff000000"
android:layout_alignParentLeft="true" />
<TextView
android:text="Step 2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@ id/step2TextView"
android:textStyle="bold"
android:textColor="#ff000000"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_toRightOf="@ id/step1TextView"
android:gravity="center" />
<TextView
android:text="Step 3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@ id/step3TextView"
android:textStyle="normal"
android:textColor="#ff000000"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center_horizontal"
android:layout_toRightOf="@ id/step2TextView"
android:layout_alignParentRight="true"
android:layout_alignWithParentIfMissing="true" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:layout_below="@ id/step1TextView">
<RelativeLayout
android:id="@ id/highlightFooter1Layout"
android:layout_width="fill_parent"
android:layout_height="10dp"
android:background="#ffffffff">
<LinearLayout
android:id="@ id/highlightFooter11Layout"
android:layout_width="2dp"
android:layout_height="70dp"
android:background="#ffe9e9e9"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<LinearLayout
android:id="@ id/highlightFooter12Layout"
android:layout_width="2dp"
android:layout_height="70dp"
android:background="#000000"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_toRightOf="@ id/highlightFooter11Layout" />
<LinearLayout
android:id="@ id/highlightFooter13Layout"
android:layout_width="2dp"
android:layout_height="70dp"
android:background="#ffe9e9e9"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_toRightOf="@ id/highlightFooter12Layout" />
</RelativeLayout>
<RelativeLayout
android:id="@ id/highlightFooter2Layout"
android:layout_width="fill_parent"
android:layout_height="10dp"
android:background="#ffe9e9e9"
android:layout_below="@ id/highlightFooter1Layout">
<LinearLayout
android:id="@ id/highlightFooter21Layout"
android:layout_width="50dp"
android:layout_height="5dp"
android:background="#ffff8b03"
android:layout_alignParentTop="true"
android:layout_marginLeft="65dp" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<ScrollView
android:id="@ id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Your phone number has been successfully verified . Please enter the following details to begin."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/textView1"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginRight="10dp"
android:background="#ffffffff"
android:textColor="#ff000000" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/stateSpinner"
android:background="#ffe9e9e9"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/districtSpinner"
android:background="#ffe9e9e9"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/constSpinner"
android:background="#ffe9e9e9"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1" />
<EditText
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/editText1"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#ffe9e9e9" />
<ImageView
android:src="@android:drawable/ic_menu_gallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/imageView1" />
<TextView
android:text="Chief Minister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/cmTextView"
android:gravity="center" />
<TextView
android:text="cm name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/cmNametextView"
android:gravity="center"
android:textColor="#ffff8b03" />
<TextView
android:text="Member of Parliament"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/mpTextView"
android:gravity="center" />
<TextView
android:text="mp name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/mpNameTextView"
android:gravity="center"
android:textColor="#ffff8b03" />
<TextView
android:text="Member of Legislative Assembly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/mlaTextView"
android:gravity="center" />
<TextView
android:text="mla name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/mlaNameTextView"
android:gravity="center"
android:textColor="#ffff8b03" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@ id/buttonLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<Button
android:text="Next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@ id/button1"
android:layout_gravity="bottom"
android:autoText="false"
android:layout_weight="1"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginBottom="0dp"
android:background="#ffff8b03"
android:textStyle="bold"
android:textColor="#ffffffff"
android:textSize="20dp"
android:minHeight="50dp"
android:maxHeight="50dp" />
</LinearLayout>
Комментарии:
1. Добавьте </LinearLayout> в конце вашего xml, по крайней мере, просто чтобы закрыть его 🙂 Если это не поможет, я бы начал удалять каждый макет один за другим.
2. извините, @Casper Skoubo, ваш комментарий сработал для меня, но я по ошибке отменил голосование за ваш комментарий. Мне очень жаль.
3. Нет проблем, вы это исправили, так что для меня это круто 🙂
4. @Casper Skoubo большое вам спасибо
Ответ №1:
Как предложил Каспер, добавьте </LinearLayout>
в конце вашего xml и добавьте android:layout_weight="1"
к вам ScrollView
и удалите его из LinearLayout
с помощью вашей кнопки.