RoCk February 2016

Can I Use The INCLUDE LAYOUT To ScrollView In My Activity?

Good day, I'm having a problem with my xml layout. I create an another xml file share_app_scroll(ScrollView Layout) and included it in my ShareApp.xml .

The Problem is, my toolbar/action bar don't appear. All I can see, is my scrollview layout that I created. Is this possible to include the scrollView layout?. Here's my Code.

<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"
android:fitsSystemWindows="true"
tools:context=".activities.ShareAppActivity">

<!--Include ActionBar/Toolbar-->
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/toolbar"
    android:elevation="8dp"
    android:minHeight="?attr/actionBarSize"
    android:background="@color/colorPrimary">
</android.support.v7.widget.Toolbar>

    <include
        android:id="@+id/share_scrollview"
        layout="@layout/share_extend_scrollview"
        android:layout_height="match_parent"
        android:layout_width="match_parent"/>

MissingToolbar

Sorry for the blurred picture. Thank you in advanced.

Answers


BlueSlimShady February 2016

The problem will be in the manifest file. Check if the java file for your xml has a android:theme="@style/AppTheme.NoActionBar" in the manifest. remove the no action bar and it will appear. if you are talking about during the design view. next to the api level there is app theme. change that to any except .NoactionBar


Vivek Mishra February 2016

You are using relative layout as your parent layout therefore you have to align your include layout below toolbar.Like this

    <include
            android:id="@+id/share_scrollview"
            layout="@layout/share_extend_scrollview"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:layout_below="@+id/toolbar"/>

Post Status

Asked in February 2016
Viewed 2,388 times
Voted 8
Answered 2 times

Search




Leave an answer