2014-10-16 6 views
0

Как добавить кнопку за пределы этого LinearLayout?Android - Добавить кнопку вне LinearLayout

Мне нужно, чтобы оно было на дне. Я попробовал это сам несколькими способами, но он добавляет одну и ту же кнопку в каждую строку! Буду признателен за помощь, спасибо!

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="5dp" > 
<CheckBox 
    android:id="@+id/checkBox_alarm_active" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:focusable="false" 
    android:padding="5dp" /> 
<View 
    android:id="@+id/view1" 
    android:layout_width="1dp" 
    android:layout_height="match_parent" 
    android:layout_marginRight="10dp" 
    android:background="#CCCCCC" 
    android:paddingRight="10dp" /> 
<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:paddingBottom="5dp" 
    android:paddingTop="5dp" > 
<TextView 
    android:id="@+id/textView_alarm_time" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 
<TextView 
    android:id="@+id/textView_alarm_days" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textAppearance="?android:attr/textAppearanceSmall" /> 
</LinearLayout> 
</LinearLayout> 

Примечание для редакторов: Я видел другие подобные вопросы, но проблема немного отличается для меня, так что те не работают.

ответ

0

, если вы хотите быть в точном bottomview макета, то сделать это

<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" 
    tools:context=".MainActivity" > 

    <LinearLayout 
     android:id="@+id/linearlayot" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="5dp" > 

    <CheckBox 
     android:id="@+id/checkBox_alarm_active" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:focusable="false" 
     android:padding="5dp" /> 

    <View 
     android:id="@+id/view1" 
     android:layout_width="1dp" 
     android:layout_height="match_parent" 
     android:layout_marginRight="10dp" 
     android:background="#CCCCCC" 
     android:paddingRight="10dp" /> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:paddingBottom="5dp" 
     android:paddingTop="5dp" > 

     <TextView 
      android:id="@+id/textView_alarm_time" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" /> 

     <TextView 
      android:id="@+id/textView_alarm_days" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 
    </LinearLayout> 
    </LinearLayout> 

    <Button 
    android:id="@+id/buttontoadd" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/linearlayot" 
    android:layout_centerHorizontal="true" 
    android:text="Button" /> 

</RelativeLayout> 

, но если вы хотите быть в крайнем нижнем зрении, что является родителем Дном ​​изменения к этому. . (изменить идентификатор = "@ + идентификатор/buttontoadd")

<Button 
    android:id="@+id/buttontoadd" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:text="Button" /> 

поддерживать его position..Let мне знать, если это помогает ....

EDIT: изменить

<LinearLayout 
     android:id="@+id/linearlayot" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingLeft="5dp" > 

в

<LinearLayout 
     android:id="@+id/linearlayot" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:paddingLeft="5dp" > 
+0

Спасибо! Решила мою проблему! –

+0

Добро пожаловать @ AnonymousMouse – Elltz

+0

Подождите, я ошибся. Он показывает, где это должно быть в графическом макете с использованием Eclipse. Но я получаю ту же проблему на реальном устройстве oO –

Смежные вопросы