Как разместить кнопку в позиции чуть выше дна в Android - PullRequest
1 голос
/ 26 сентября 2011

Мне нужно разместить кнопку внизу экрана, оставляя немного места под ней. Другими словами, я использую эти два атрибута для своей кнопки -

android:layout_alignParentBottom="true" 
android:layout_marginBottom="20dp"

но атрибут margin не будет работать, когда я использую alignParentBottom, а кнопка придерживается только внизу Подскажите пожалуйста, как разместить его чуть выше дна.

Вот XML

<RelativeLayout
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:gravity="center_horizontal"
 android:background="@drawable/board"
 android:layout_marginLeft="10dp"
 android:layout_marginRight="60dp"
 android:layout_marginTop="15dp"
 android:layout_marginBottom="10dp">


        <TextView 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:text="Type of Lesion"
            android:textColor="#8B0A50"
            android:layout_marginTop="40dp"
            android:id="@+id/disease_listheader_textview"
             android:drawableBottom="@drawable/underline"/>

        <ListView 
          android:id="@+id/disease_listview"
          android:layout_below="@id/disease_listheader_textview"
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content"
          android:divider="@drawable/divider"
          android:layout_marginLeft="40dp"
          android:layout_marginBottom="50dp"
          android:cacheColorHint="#00000000"/>  

        <Button  
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content"
             android:id="@+id/disease_search_button"
             android:layout_centerHorizontal="true"
             android:background="@drawable/disease_search_btn" 
             android:layout_alignParentBottom="true"
             android:layout_marginBottom="20dp"/>

     </RelativeLayout>

Ответы [ 3 ]

3 голосов
/ 26 сентября 2011

просто измените значение атрибута относительной высоты макета на fillparent, как

</p> <pre><code><RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" .................../>


надеюсь, это поможет вам

1 голос
/ 26 сентября 2011

Можете ли вы попробовать это?

  1. Замените тег Button на тег, указанный ниже. Я пытаюсь обернуть кнопку в другой макет макета

    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    android:paddingBottom="20dp">
    
    <Button  
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content"
             android:id="@+id/disease_search_button"
             android:background="@drawable/disease_search_btn" 
             android:layout_marginBottom="20dp"/>
    
    </LinearLayout>
    
0 голосов
/ 26 сентября 2011

Это работает так, как вы хотели

<RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="match_parent" android:layout_height="fill_parent">
    <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="20dip"></Button>
</RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...