How can I achieve something like the highlighted area below? - android

I have been trying to design something like this in android code but have not been able to. I have little android experience. You you be able to help me by posting the full code for how to be able to do this.

Add :
In your theme attribute:
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowContentOverlay">#null</item>
Then just put an imageview in a relativelayout and some text on and you're good to go!

Related

xamarin android alignParentRight style

can you tell me how can I add alignParentRight into my xml style?
<style name="My_Style">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">75dp</item>
<item name="android:background">#color/Gray_75</item>
**<item name="android:alignParentRight">true</item>**
</style>
yes but I need to add it programatically for dynamic and I will add only style and thats all.
Generally you can't do that programmatically. What we can do is:
Create two different styles, one with <item name="android:alignParentRight">true</item> and the other one not, apply them to the control when it is needed. Since in which scenario of your styles will be used is not clear in your question, maybe you can look into State List.
I personally think it is more straight if we directly set the Layout Parameters in code behind, for example:
var parameters = btn.LayoutParameters as RelativeLayout.LayoutParams;
parameters.AddRule(LayoutRules.AlignParentRight);
The btn in this code refer to a Button control.

Android Preference Screen, change color behind title text

I have changed the background color to my preference screen but the title bar is acting strange.
I have this as my theme set in the manifest for the preference activity as below:
<style name="PrefTheme">
<item name="android:background">#color/activity_default_bg_color</item>
</style>
Which works, but the title bar now looks like this:
I have tried playing with a bunch of other properties to change it but can't find the correct one.
Thanks
Steve
Edit:
Looking at the edit text popups they have also changed
I tried to change the popups with, but didn't work
<item name="android:windowBackground">#color/activity_default_bg_color</item>
<item name="android:popupBackground">#color/activity_default_bg_color</item>
This is the problem:
<item name="android:background">#color/activity_default_bg_color</item>
I had to use this instead
<item name="android:windowBackground">#color/activity_default_bg_color</item>
This fixed both the problems mentioned above.
Hope this helps someone.
Thanks
Steve
Edit:
End Result:

ViewPageIndicator Tabs - How to achieve the following style?

I'm using ViewPageIndicator to customize the looks of the tabs in my app but I'm really new to android so I don't really know to get exactly where I want to.
Here's a gif that I made to show how I want it to behave: http://i.imgur.com/1FSw5ae.gif
I couldnt find any options to make the make the background semi-transparent like android:background_alpha or something , instead I found this topic How to make a background 20% transparent on Android but it didn't worked either.
As for the tabs switching color depending on the content I have no idea how to get there =/
If anyone could help I'd be really glad.
Here's the code for the styles:
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:textSize">16sp</item>
<item name="android:textColor">#6abd45</item>
<item name="android:background">#80000000</item>
</style>
Thanks in advance.

Android renders RGB values wrong. How to fix it?

I have very strange problem. To explain it, I will use this simple example. I'm trying to change action bar backgroung color (or button color, it is no metter). So I use following theme, which I apply to my app.
<style name="Theme.App" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/Theme.App.ActionBar</item>
</style>
<style name="Theme.App.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#262626</item>
<item name="android:icon">#drawable/actionbar_logo</item>
<item name="android:displayOptions">showHome</item>
<item name="android:textColor">#ffffff</item>
</style>
As you can see I use #262626 color as a background of ab. On my mockups in Adobe Photoshop and Illustrator it looks like this:
http://i.stack.imgur.com/hA7Re.png
But in my emulator (and even on my G Nexus) it looks like this:
http://i.stack.imgur.com/MBSTL.png
As you can see it uses different color. It is #212421, instead of #262626.
I'm tried to use #ff262626, tried to use 9-patch png (with the same color) as a background, but the result is the same.
I found some questions, which look like mine. Some of answers sounds like: "some Android devices do not support 32-bit png (or 16 and so on)".
So the questions are: How to fix it? How to make actionbar looks like I want? How do you create your own png-resources, which looks good? What am I doing wrong?
I would greatly appreciate for your help. Alex.
P.S. Sorry for my English:)

Change font/typeface when button is pressed

I already how to change the style of an element with selector but I found nothing about the typeface...
Is it possible to do with ? Or is there another way?
Sadly, right now it is not possible.
There is a ticket for that in the Android code repo :
https://code.google.com/p/android/issues/detail?id=8941
Your best option is to manage it yourself in ontouch listeners (and yes this is ugly) or implement these new selectors yourself.
Typeface can easily be an element of your style... If you're using default android styles, then the idea would be to extend whatever style you're implementing and just change the elements you need. like the following style element, taken from the android styles and themes documentation:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="#android:style/TextAppearance.Medium">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
Then apply this style in your selector, just like you already know how to do.
The other option is, of course, to do it in code, but the selector is much cleaner
When button is clicked,Use below code to change font of the text(custom typeface).
Put your font under main->assets->fonts directory.
//change font when button pressed
val typeFace = Typeface.createFromAsset(activity!!.assets,"fonts/sf_semi_bold.ttf")
buttonAbout.setTypeface(typeFace)
TextView.setTypeFace() Use Ctrl+Space to show a giant list of classes for TextView or anything in general on.

Categories

Resources