Wrox Programmer Forums
|
BOOK: Beginning Android Tablet Application Development
This is the forum to discuss the Wrox book Beginning Android Tablet Application Development by Wei-Meng Lee; ISBN: 978-1-1181-0673-0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Tablet Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2011, 03:35 AM
Registered User
 
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default PreferenceFragment: How to remove transparency?

In the PreferenceFragment Try It Out, the resulting fragment is transparent (see figure 3-22), you can still see the "Hello world" in the background fragment. If there is text on the background fragment, this can make it very difficult to read the preferences.

How can I make the preference fragment opaque? Thanks.
 
Old November 27th, 2011, 04:26 AM
Registered User
 
Join Date: Nov 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sovled

Ok I figured it out. I had defined the initial fragment in the XML file for the main view. You can't replace a fragment defined in this way via a fragment transaction - you can only replace fragments that you added programmatically. That's why the initial fragment remained visible in the background.

So the solution was to remove the initial fragment from main.xml layout file, and add it to the initial view using fragmentTransaction.add() instead. This way the initial fragment is successfully replaced when the preference fragment is called, and is no longer visible in the background.
 
Old December 2nd, 2011, 06:19 PM
Registered User
 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I ran into this exact same problem.

I'm creating an app with 2 seperate fragments, both within their own RelativeLayout. These fragments get added programmatically to these layouts during the initialization stage.
When trying to call the PreferenceFragment, it turns transparent exactly like you described.
I'm trying to replace the content in my fragments, it's still transparent. When I try to replace the entire content of the app, it's still transparent.

Now from your comment I understand you managed to fix it by removing the fragments from your main layout file, but how did your layout end up after that?

I'm pretty sure I'm on the right track but I'd like to see your final fix to push me in the right direction.
 
Old December 3rd, 2011, 02:07 AM
Registered User
 
Join Date: Nov 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
We additional openness to some div container. I want to take away the transparency of the contents of which div. I want to add some text in it, but the text seems to bee transparent similar to the pot, even when it has been assigned a different div and set transparency in order to 100%
How do i do this?
thanks
 
Old December 3rd, 2011, 07:08 AM
Registered User
 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I eventually fixed it by just calling a new Intent that launches the Preference screen.
Quite a simple fix, but it works fine.

Prefs.java
Code:
public class ReaderPreferences extends PreferenceActivity {
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			// --load the preferences from an XML file---
			addPreferencesFromResource(R.xml.preference);
		}

In my main screen when pressing a button:

Code:
Intent i = new Intent(this, Prefs.class);
			startActivity(i);

That's all. After setting the preferences simply press the back button and you're done.

Dont forget to add Prefs to your Manifest!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitmap Transparency tahcue C++ Programming 0 December 19th, 2007 07:45 PM
ImageList/transparency problem jacob C# 0 February 27th, 2006 08:37 AM
Transparency and repainting Volt9000 C# 0 December 18th, 2004 01:00 AM
PNG Transparency in IE richard.york Javascript 4 January 19th, 2004 08:26 PM
Transparency Problem blah VB.NET 2002/2003 Basics 0 October 30th, 2003 02:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.