2017-02-20 1 views
0

у меня есть линейной компоновки на мой взглядКак выровнять 2 мнения в одной раскладке, поэтому один в большинстве сверху, а другой на самой нижней

имеет 2 вид внутри него, одна «кнопка» и один «frameLayout»

делает тяжесть: «верх» для родительского макета, позиционирование 2 внутри взглядов на самом верхнем

делает тяжесть: «дно» для родительского макета, позиционирование 2 внутри взглядов на самый нижний

как установить кнопку на самом дне И «frameLayout» на самых верхних

моих текущих кодов:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FFF" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:gravity="bottom"> 
    <FrameLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/frameLayout1" 
     android:layout_gravity="top"> 
     <ListView 
      android:minWidth="25px" 
      android:minHeight="25px" 
      android:id="@+id/notifiers" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </FrameLayout> 
    <Button 
     android:text="+" 
     android:id="@+id/newTask" 
     android:background="#13F" 
     android:textSize="20pt" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" /> 
</LinearLayout> 

ответ

2
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FFF" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:gravity="bottom"> 
    <FrameLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_alignParentTop="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/frameLayout1" 
     android:layout_gravity="top"> 
     <ListView 
      android:minWidth="25px" 
      android:minHeight="25px" 
      android:id="@+id/notifiers" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </FrameLayout> 
    <Button 
     android:text="+" 
     android:id="@+id/newTask" 
     android:background="#13F" 
     android:textSize="20pt" 
     android:layout_alignParentBottom="true" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" /> 
</RelativeLayout> 

использовать относительное расположение для ваших целей, это позволит гораздо больший контроль над относительными позициями

+0

, когда я использовал относительное расположение, он запрещен любой другой вид, чтобы поставить на него :)) –

+0

однако этот код работал хорошо со мной - спасибо очень –

+0

проверить мой ответ он отлично работает без изменения ваш основной макет! –

0

Вы можете использовать чтобы достичь того, чего вы хотите.
Добавить android:layout_weight="1"
в FrameLayout

1

проверить этот код я только что отредактировал код работает отлично, как вы хотите!

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FFF" 
    android:minWidth="25px" 
    android:minHeight="25px" 
    android:gravity="bottom"> 
    <FrameLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_weight="9" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:id="@+id/frameLayout1" 
     android:layout_gravity="top"> 
     <ListView 
      android:minWidth="25px" 
      android:minHeight="25px" 
      android:id="@+id/notifiers" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
    </FrameLayout> 
    <FrameLayout 
     android:layout_gravity="center_horizontal" 
     android:layout_weight="1" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp"> 
    <Button 

     android:text="+" 
     android:id="@+id/newTask" 
     android:background="#13F" 
     android:textSize="20pt" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" /> 
    </FrameLayout> 
</LinearLayout> 
Смежные вопросы