2015-08-12 3 views
-1

Я сделал макет, который имеет кнопки в нижней части:Android Lollipop устройство не показывает нижние кнопки

<FrameLayout 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="my.site.com.myapp.fragments.NewsFragment"> 

<!— TODO: Update blank fragment layout —> 

<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<ListView 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:id="@+id/newsListView" 
android:layout_alignParentBottom="true" 
android:layout_alignParentTop="true" 
android:layout_marginBottom="48dp" /> 

<LinearLayout 
android:orientation="horizontal" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
android:id="@+id/linearLayout4"> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="All Events" 
android:id="@+id/fromNewsToAllEventsButton" 
android:layout_weight="1" 
android:background="@android:color/holo_blue_bright"/> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:id="@+id/fromNewsToAllSharesButton" 
android:layout_weight="1" 
android:text="Shares" 
android:background="@android:color/holo_blue_dark"/> 
</LinearLayout> 
</RelativeLayout> 
</FrameLayout> 

Android 4.1 в состоянии показать нижние кнопки в то время как Android 5.1 нет.

Android 5.1 and Android 4.1

На левой стороне Android 5.1 на правой стороне Android 4.1.

Поддерживает ли Android 5.1 дополнительные конфигурации на макетах? Если это особенность новых версий, то это плохая функция.

Основная проблема заключается в том, что если этот макет размещен на Activity, он показывает кнопки. Однако он не отображается в Fragment

+0

Почему вы установили два свойства: андроид: layout_alignParentBottom = "истинный" андроид: layout_alignParentTop = "истина" в ListView? – SANAT

+0

Имеет ли это влияние в моей проблеме? Когда я разместил listview, он автоматически добавил их. –

+0

Удалить андроид: layout_alignParentBottom = "true" из списка. – SANAT

ответ

1
<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="my.site.com.myapp.fragments.NewsFragment"> 


    <ListView 
     android:id="@+id/newsListView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_above="@+id/buttonLayout" /> 

    <LinearLayout 
     android:id="@+id/buttonLayout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:orientation="horizontal"> 

     <Button 
      android:id="@+id/fromNewsToAllEventsButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@android:color/holo_blue_bright" 
      android:text="All Events" /> 

     <Button 
      android:id="@+id/fromNewsToAllSharesButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:background="@android:color/holo_blue_dark" 
      android:text="Shares" /> 
    </LinearLayout> 
</RelativeLayout> 
+0

Почему у вас есть два 'ids' в' linear layout'? –

+0

сейчас проверьте мой обновленный код –

+0

Я использовал ваш код. Теперь появляется только белая линия, но без кнопок. –

0

Я должен исправить ваш макет, заменив ваш xml кодом ниже.

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout 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="my.site.com.myapp.fragments.NewsFragment"> 


     <RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:id="@+id/linearLayout4"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="All Events" 
      android:id="@+id/fromNewsToAllEventsButton" 
      android:layout_weight="1" 
      android:background="@android:color/holo_blue_bright"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/fromNewsToAllSharesButton" 
      android:layout_weight="1" 
      android:text="Shares" 
      android:background="@android:color/holo_blue_dark"/> 
    </LinearLayout> 


    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/newsListView" 
     android:layout_alignParentTop="true" 
     android:layout_above="@id/linearLayout4" 
     android:layout_marginBottom="5dp" 
     /> 

</RelativeLayout> 
</FrameLayout> 
+0

Я заменил свой xml и ничего не изменился. –

+0

это работает как шарм в моем коде –

+0

Он работает, когда Android 4. *, но не в Android 5. * –

0
<FrameLayout 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="my.site.com.myapp.fragments.NewsFragment"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <ListView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/newsListView" 
      android:layout_alignParentTop="true"/> 

     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:id="@+id/linearLayout4"> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="All Events" 
       android:id="@+id/fromNewsToAllEventsButton" 
       android:layout_weight="1" 
       android:background="@android:color/holo_blue_bright"/> 

      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/fromNewsToAllSharesButton" 
       android:layout_weight="1" 
       android:text="Shares" 
       android:background="@android:color/holo_blue_dark"/> 
     </LinearLayout> 
    </RelativeLayout> 
</FrameLayout> 

Вот мой результат:

Output

+0

Я заменил свой xml на ваш. Ничего не изменилось –

+0

Это фрагмент или активность? В Деятельности это работает, но не в Фрагменте –

+0

это Деятельность. – Kushan2

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