Кнопка входа в макет Android - PullRequest
0 голосов
/ 22 апреля 2011

У меня есть один XML-файл, в который я добавил один относительный макет, а под ним у меня есть две кнопки. один из них - Signin, а другой - newuser, а кнопка входа показывает некоторую проблему

Я установил кнопку входа слева от кнопки newuser, но она закрывалась, даже я пытался с layout_marginTop = -42 при запуске приложения как есть, я имею в виду, что оно не остается слева от кнопки newuser , Две кнопки должны быть между центром и дном

пожалуйста, помогите мне, спасибо ..!


Ответы [ 2 ]

1 голос
/ 22 апреля 2011

Вы можете поместить две кнопки в горизонтальный LinearLayout и установить для них layout_weight для обоих значений 1. Установка одинакового веса на View с в LinearLayout заставляет их занимать 50% пространства. соответственно. Тогда вы можете взять эту «панель кнопок» целиком.

Ниже приведен пример:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:padding="10dip">     

    ....................

    <LinearLayout 
        android:layout_alignParentBottom="true"              
        android:layout_gravity="center_horizontal"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="horizontal">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"/>
     </LinearLayout>
</RelativeLayout> 
0 голосов
/ 22 апреля 2011

Попробуйте

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/ll_one" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
    <TextView android:id="@+id/TextView01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="User Name:"/>
    <EditText android:id="@+id/EditText01"
    android:layout_width="200px"
    android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:id="@+id/ll_two" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/ll_one">
    <TextView android:id="@+id/TextView02"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Password:"/>
    <EditText android:id="@+id/EditText02"
    android:layout_width="200px"
    android:layout_height="wrap_content"
    android:password="true"
    android:inputType="textPassword"/>
</LinearLayout>
<LinearLayout android:id="@+id/ll_three" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentBottom="true">
    <Button 
        android:layout_height="wrap_content" 
        android:text="Sign In"
        android:id="@+id/Button01"
        android:layout_width="fill_parent" 
        android:layout_weight="1"/>
    <Button 
        android:layout_height="wrap_content" 
        android:layout_width="fill_parent" 
        android:id="@+id/Button02"
        android:text="New user"
        android:layout_weight="1"/>
 </LinearLayout>
</RelativeLayout>

Отредактировано

<LinearLayout android:id="@+id/ll_three" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_below="@+id/ll_two" android:gravity="center">
    <Button 
        android:text="Sign In"
        android:id="@+id/Button01"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"/>
    <Button 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:id="@+id/Button02"
        android:text="New user"/>
 </LinearLayout>

Вы ищете это?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...