Question

screenshot

I am using android.support.v7 library for action bar support on old devices and android.support.v4 for fragment support.

My application on version Android 2.* doesn't display ActionBar correctly, it stretched to fill the screen and frame layout doesn't showing. ActionBarDrawerToggle button clickable, but it doesn't do anything.

There are no errors or warnings shown in the LogCat output.

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.test"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
        <activity
            android:name="com.example.test.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

In MainActivity:

...
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBar.OnNavigationListener;
import android.support.v7.app.ActionBarActivity;

...
public class MainActivity extends ActionBarActivity
...

MainActivity layout:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- The main list content view -->
    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/fragmentContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- The navigation drawer -->
    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:background="@color/light_gray"
        android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>

What am I doing wrong?

Was it helpful?

Solution

I solved this problem by removing v4 jar support library from "libs" folder and removing v7 support library folder, which has been imported from eclipse project and adding this to build.gradle file in dependencies section:

compile "com.android.support:support-v4:18.0.+"
compile "com.android.support:appcompat-v7:19.1.0+"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top