Android PreferenceScreen title bar removes

I want to get rid of the top header in preferences settings and all child screens. The problem that I am currently facing does not occur on jelly bean, but in older versions. If I cannot delete it, I would like to change its behavior so that the title on the screen of the child will not be transferred from the list item.

I did not set anything for the title on this screen, the text properties were copied by the system from the parent screen. The name on the parent screen was setTitle () in the root preference category. The problem exists on 2.3.6

enter image description here

enter image description here

+4
source share
5 answers

As you noticed, this problem is fixed in the latest versions of Android. This is caused by an error in which the nested preferences were hard-coded to always use either the internal Theme or Theme_NoTitleBar from the framework. the fix that fixed the bug seems to have merged some time after the release of Gingerbread.

The easiest way to get around this error (just to get rid of the unwanted title text) is to add onPreferenceClickListener to your PreferenceScreen object and set the title to null. For the code you posted, it will look like this:

  particleSettings.setLayoutResource(R.layout.iconpreferencee); particleSettings.setKey("screen_preference"); particleSettings.setTitle(Html.fromHtml("" + "Particles" + "")); particleSettings.setSummary(Html.fromHtml("<font color=\"#7c71d8\">" + "Count , type , color , size, gitter ... " + "</font>")); // workaround for Android bug 5351628 particleSettings.setOnPreferenceClickListener( new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference pref) { final PreferenceScreen screen = (PreferenceScreen) pref; screen.getDialog().setTitle(null); return false; } }); 

Hope this helps! :)

+1
source

Use this in AndroidManifest:

 android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
+4
source

The following worked for me:

Create each preference as a separate XML and a separate Activity! . This will prevent the inheritance of such properties.

You can then call the child preference from the parent preference as follows:

 <Preference android:key="TODO" android:title="@string/TODO" android:summary="@string/TODO" > <intent android:action="com.example.project.preference.child1" /> </Preference> 

And your preference for your child should have the same action defined on the manifest

 <action android:name="com.example.project.preference.child1" /> 

Make sure com.example.project.preference.child1 is unique!

Now, in the values ​​of /styles.xml, add the following:

 <style name="app_theme_no_title_pref" parent="android:Theme.Light"> <item name="android:windowNoTitle">true</item> </style> 

Of course, you can change the android: Theme.Light to everything you need.

In Manifest, add this to all Activity, parent and children settings:

 android:theme="@style/app_theme_no_title_pref" 

So, in your manifest, your child's preference. Actions should look like this:

 <activity android:name=".TODO" android:label="@string/TODO" android:theme="@style/app_theme_no_title_pref"> <intent-filter> <action android:name="com.example.project.preference.child1" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> 
0
source

use this in your java file:

 requestWindowFeature(Window.FEATURE_NO_TITLE); 
-1
source

Can you try to remove the header first: Add a superclass, Like (for example):

 public class FullScreenActivity extends Activity 

In the FullScreenActivity application, add a method:

  private void addFlags() { this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().addFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); Log.d(TAG, "add flags"); } 

And call this method onCreate of FullScreenActivity

So...

You can carry out your activities and all subclasses, possibly FullScreen by flags.

 public class MyActivity extends FullScreenActivity 

Try this to check the solution ... and you can set a Title for each operation (if not, use the superclass header).

-1
source

All Articles