Reputation: 7873
I have made layout which has buttons at bottom part:
<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 able to show bottom buttons while Android 5.1 does not.
On the left side Android 5.1 on the right side Android 4.1.
Does Android 5.1 requires additional configurations on layouts? If it is feature of new versions, then it is bad feature.
The main problem is that If this layout is placed on Activity it shows buttons. However it fails to show in Fragment
Upvotes: 0
Views: 478
Reputation:
<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>
Here is my output :
Upvotes: 0
Reputation: 622
<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>
Upvotes: 1
Reputation: 3372
I have to fix your layout replace your xml with below code.
<?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>
Upvotes: 0