D
D
DeusModus2013-09-18 19:03:53
Android
DeusModus, 2013-09-18 19:03:53

Fragment content indent from Action Bar and Tab controls when using Support Library?

Hey!
I am following the path indicated in the Guides of the official documentation, but I came across one unpleasant problem:
f5643531b28d89bdd043bf39a5db1072.jpg
I generally understand what this is connected with - the absolute positioning of the menu, but how to fix it broke my head.
Using android:paddingTop="?attr/actionBarSize" in the fragment layout only helps if the Action Bar and Tabs are on the same line (landscape mode on my Desire HD), in portrait mode the tabs are broken.
In all examples, be it not okay, the content is centered around the entire layout and there is no such problem (three lines of text, after all).
Ask for help from more experienced colleagues.
Manifesto:

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

Main layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
</LinearLayout>

Menu:
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:player="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_prefs"
        android:icon="@drawable/ic_drawer"
        android:title="@string/action_preferences"
        player:showAsAction="always"/>
</menu>

Layout из фрагмента с багом:
<source lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
    >
    <ListView
        android:id="@+id/audioListView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </ListView>
</LinearLayout>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Edward, 2013-09-18
@ED98

if you have a ListFragment as a tab, and you add it using FragmentTransaction.add(int containerViewId, Fragment fragment) , then you need to use android.support.v7.appcompat.R.id.action_bar_activity_content as int

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question