Android theme without the edge - android

I'm using the Eclipse GUI for android. I want to use the full screen and I'm searching for the attribute, that disables the edge in a theme. I'm using the NoTitleBar theme and a relative layout and I can't place buttons on the edgde of the screen. There are like 10pixels I can't reach. Something like item name="android:windowNoEdge" true /item. In addition I can't really make the views/buttons as big as i want, when I try to drag them too a different/bigger shape/size they just shrink back too the original shape/size.

Method 1:
Put this in your onCreate method
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
before setContentView()
Method 2:
This will make entire application to full-screen, instead of just one Activity.
<application
...
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
... >

Related

How to make ViewGroup translucent (NOT transparent)

I found a description about the difference of transparent and translucent. These are the important parts:
What does translucent mean? If you were writing about a pane of glass,
but that pane of glass was frosty, darkly colored, or very dirty, you
would use translucent.
What does transparent mean? If you were writing about a pane of glass,
and that piece of glass was perfectly clear, you would use
transparent. Something that is transparent allows all light to pass
through it. Clean air and the windshield of a car are transparent.
If you want to understand this deeply then look here.
I want to make a ViewGroup translucent in Android. In a video I found how to make an Activity translucent. What they do is defining the following styles and colors:
<color name="transparent_green_color">#8800ff00</color>
<style name="TranslucentGreen" parent="android:Theme.Translucent">
<item name="android:windowBackground">#color/transparent_green_color</item>
</style>
And then in the manifest the within the application tag they add this new style as a theme:
<application
android:theme="#style/TranslucentGreen"
...>
...
</application>
What I want to do is NOT to make an Activity translucent but to make a ViewGroup translucent.
My layout is structured like this:
<FrameLayout>
<RelativeLayout>
...
</RelativeLayout>
<RelativeLayout>
...
</RelativeLayout>
</FrameLayout>
The second RelativeLayout shall be translucent and the first one shall be visible a bit through the translucent RelativeLayout. How to do that?
Using the Blurry library solved my problem. So if the second ViewGroup (in my case second RelativeLayout) has to be at the top and the first one has to shine through translucent, then you need to call something like:
Blurry.with(context).radius(25).sampling(2).onto(viewGroup);
and then you have the desired effect. For going back to the old view state without translucency you can just use this method:
Blurry.delete(viewGroup)
on the desired view. I like that library because it's very compact.
If you are not able to use external libraries you should maybe start with this Medium article. It works with RenderScript and Bitmap class. Bu It shall be possible to create Bitmaps from ViewGroups.

android: set background color for the entire screen dynamically, or how to set actionbar to overlay layout, but not overlap content

My app uses the Theme.Wallpaper family, which means the current wallpaper is used as the app's background.
This may cause readability issues (depending on the user's favorite wallpaper) so I want to allow the user to choose an image as a background.
The way I am trying to implement it is:
#Override
protected void onResume() {
// Get wallpaper preferences to check if user selected a wallpaper and
// display it
SharedPreferences wallpaperPref = getSharedPreferences(WallpaperActivity.WALLPAPER_PREFERENCES, MODE_PRIVATE);
int selectedWallpaper = wallpaperPref.getInt(WallpaperActivity.SELECTED_WALLPAPER, 0);
if (selectedWallpaper != 0) {
findViewById(R.id.pager).setBackgroundResource(selectedWallpaper);
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(selectedWallpaper));
} else {
findViewById(R.id.pager).setBackgroundColor(Color.TRANSPARENT);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
super.onResume();
}
The shared preference contains the resource id of the selected wallpaper.
My problem is the titlebar and actionbar do not respond to this. Is there a way to make them also receive the new background?
Make the background of the title bar and action bar transparent.
Set your Window ActionBar Overlay to true.
Pad your main view by the height of the ActionBar so the ActionBar doesn't cover up any of the content.
Your ActionBar will now sit over the background view, instead of above it. It will be transparent, so as to allow the background to show through, and it will not be covered up by the ActionBar.
Here's what I ended up doing, thanks to #Sky for the help:
On my app's style I added this item: <item name="windowActionBarOverlay">true</item> which makes the actionbar overlapp my layouts. This is the solution to the original problem, but of course it is not useable as long as the layout contents are overlapped, so here's how to overcome this:
On the dimen.xml file I added these two dimentions to be used as paddingTop values
dimen name="actionBarSize" 56.0dip dimen,
dimen name="actionBarWithTabsSize" 112.0dip dimen.
(add the '<' and '/> in place)
These are necessary to API 10 and below, for API-11 and above there is ?android:attr/actionBarSize that can be set as the paddingTop value.
On each top-level layout - that is the top level element on every layout file that is being inflated by an activity, I added a paddingTop value like this: android:paddingTop="#dimen/actionBarSize" except on the layout in which I have tabbs implemented, there I used android:paddingTop="#dimen/actionBarWithTabsSize".
On the preference.xml file in the xml folder, I added this line to the top-level PreferenceScreen element: android:layout="#layout/activity_settings".
On the layout folder I created a new layout file named "activity_settings.xml". It contains a FrameLayout as the top-level element, with this property: android:paddingTop="#dimen/actionBarSize", and within the FrameLayout there is one ListView element with id android:id="#android:id/list".
On my PreferenceActivity sub-class, right after the call to addPreferencesFromResource(R.xml.preferences); I added setContentView(R.layout.activity_settings);. This tells the preference activity to use the activity_settings.xml layout file as it's layout, and the ListView with id of "#android:id/list" as it's preference container. This way you get control of the top-level layout file in order to set it's padding.

ActionBar is hiding when keyboard appears

I'm using ActionBarSherlock. windowSoftInputMode is adjustPan (I've tried with adjustResize and adjustNothing also).
I want to keep ActionBar on screen when keyboard appears but slide my layout instead (so text remains visible).
Here is how it looks right:
And when keyboard is appeared:
Question is: how can I keep ActionBar visible while using adjustPan (so EditTexts will always be visible)?
NOTE
I can't use ScrollView to hold my View
I find out, that there may be problems with adjustResize (for some reason it's just uses adjustPan instead) when you applying FLAG_FULLSCREEN to Window of Activity:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Without this line resizing working just fine.
it looks like the layout slides up to make some space for the keyborad try:
add this to your manifest.xml:
<activity android:name=".YourActivity" android:label="#string/app_name" android:configChanges="keyboardHidden|orientation|keyboard" />
the important part is:
android:configChanges="keyboardHidden|orientation|keyboard"
android documentation manifest.xml

REMOVE upper Border layout

I have develop app in which I set layout 480 * 320, it is starting from top. But my problem is there is one in build border are display when we take a new project and it is display in all activity. So I want to disable it.
Border like
So can you tell how can I remove it or hide it?
I think what you are trying to do is hide the TitleBar of the application. You can do that by changing the application theme.
Add android:theme="#android:style/Theme.Light.NoTitleBar" in the <application> tag of your manifest file.
Any theme with .NoTitleBar should do the trick.
use any one.
Manifest:
android:theme="#android:style/Theme.NoTitleBar"
Or
java:
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestFeature(FEATURE_NO_TITLE);
in you activity's onCreate before setting the layout should remove it.
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

Apply the Android "Dialog" theme and sizing it properly

I have an activity that I would like to occur in a dialog. Is there anyway to do this from code, instead of in the manifest? I tried to do this, but it seemed to have no effect.
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_Dialog);
}
Also, the activity contains a webview and when it starts out as a dialog it's got a small amount of content and the dialog is only like 100px tall. When content fills in it scrolls inside a tiny 100px tall window in the dialog. How do I make the dialog take up more vertical space?
You can easily accomplish this via XML. Just use an XML named 'themes.xml', and place it in the values folder.
Here's a basic example, which implements a custom background:
<resources>
<style name="my_theme" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#drawable/custom_background</item>
</style>
</resources>
You'll also need to add the following line to the desired activity section of the manifest:
android:theme="#style/my_theme"
PS: I realize this is an old thread, but hopefully it helps someone nonetheless :)
I'm not aware of a way to set the dialog theme from code.
The dialog is basically as big as it needs to be to contain the content, so if you want it to be bigger you need to make some component in your view larger. Perhaps you can set the hieght of the webview to something larger. Note, use dpi, not px!
that's the solution, you can apply a theme via code, thanks to this guy :)
wasn't aware of this constructor myself
https://stackoverflow.com/a/1975508/371749

Categories

Resources