Cannot get custom notification to work Android 2.3.3 - android

I am trying to get a custom notification to work and although I have no issues with android 4.0 and upwards, I cannot get it to work correctly in 2.3.3 (API v10). Below is the result that I have:
As you can see the text is not visible, neither is the progress bar.
Below is the XML used for the RemoteView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ongoing_notif_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp" >
<ImageView android:id="#+id/ongoing_notif_image"
android:contentDescription="#string/notif_contentDesc"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:textAppearance = "#android:style/TextAppearance.StatusBar.EventContent" />/>
<TextView android:id="#+id/ongoing_notif_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/ongoing_notif_image"
android:textAppearance = "#android:style/TextAppearance.StatusBar.EventContent" />
<TextView android:id="#+id/ongoing_notif_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/ongoing_notif_image"
android:layout_below="#id/ongoing_notif_title"
android:textAppearance = "#android:style/TextAppearance.StatusBar.EventContent" />
<ProgressBar
android:id="#+id/ongoing_notif_pgStatus"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ongoing_notif_text"
android:layout_toRightOf="#id/ongoing_notif_image"
android:textAppearance = "#android:style/TextAppearance.StatusBar.EventContent" /> />
</RelativeLayout>
I have added the 'android:textApprearance' after following this suggestion stackoverflow item
Still no success though. Please note that this works fine on Android 4.0 upwards.

After spending many hours searching for it, I found the solution in another stackoverflow question and I though that I will post it here in case someone else comes across this question. The answer is here and is caused by a bug in the support library as shown here.

Related

ExpandableCardView Text Not Fully Visible

I am using this library to achieve expandable cards and it works fine except for two major concerns viz:
It requires the min api level to be 21 and previously my min api level was 16. Will this work well on lower devices. There's an option to override this in the library's manifest file but I don't think it's a good idea.
I have layout like below which contains another layout with a textview but the text is not showing fully, only the first line is visible. Here's the layout:
<com.alespero.expandablecardview.ExpandableCardView
android:id="#+id/focusCardLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/metaCard"
android:layout_marginBottom="10dp"
app:expandOnClick="true"
app:inner_view="#layout/session_inner_card_focus_pts_layout"
app:title="Focus Points" />
and the inner_view layout:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/focusPointsTV"
android:layout_margin="5dp"
android:layout_marginBottom="10dp"
android:text="You cannot win matches without scoring points so it's important your players can shoot accurately."
android:textSize="18sp"
android:padding="10dp">
</TextView>
Is this a fault in my layout or the library. I have set input_type to short/long message, still no effect.
Is there other means of expanding-collapsing cardviews android? Thanks.
I tried your code, and I think your issue come from the library.
I know a lib that resolve your issue as well, that is this library
<!-- sample xml -->
<com.ms.square.android.expandabletextview.ExpandableTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:expandableTextView="http://schemas.android.com/apk/res-auto"
android:id="#+id/expand_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
expandableTextView:maxCollapsedLines="4"
expandableTextView:animDuration="200">
<TextView
android:id="#id/expandable_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:textSize="16sp"
android:textColor="#666666" />
<ImageButton
android:id="#id/expand_collapse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
android:layout_gravity="right|bottom"
android:background="#android:color/transparent"/>
</com.ms.square.android.expandabletextview.ExpandableTextView>
It's work for me and I hope it will help you too.

Text color is changing in Android Studio but not showing on phone

I have browsed through a few places but can't find anything "exact" to solve my issue. I set code in Android Studio and the display showed my top text as orange and the bottom text as blue...which is what I intended. When I tried running it on my phone, the text color did not show as it does in Android Studio. (Just is gray text on my phone)
This is a simple bit of code as I'm currently learning from Udacity and a couple other places. Any ideas why code would show as working on Android Studio but wouldn't work on the phone? (especially when dealing with something as simple as text color?)
The code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.saoiray.happybirthday.MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="I'm awesome! Birth of a developer (^_^)"
android:textColor="#FF5722"
android:textSize="32sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Oh yeah, Stephen is awesome!"
android:textColor="#3F51B5"
android:textSize="32sp" />
<ImageView
android:id="#+id/androidparty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:src="#drawable/androidparty"
tools:ignore="ContentDescription" />
</RelativeLayout>
I had the same problem, and i disabled the "High contrast fonts" from the Settings-> Display -> Visibility enhancements , of the phone and now the textColor appears like in Virtual Device

How to port RelativeLayout from Android source code?

Background
I have a card-like UI on my app, which uses a RelativeLayout.
The problem
Recently I've discovered that on at least one device ( or rom, or andorid version), when I switch to an RTL language (such as Hebrew), everything got messed up.
This has happened only on LG G2 with Android V4.2.2 .
Here's what I see:
If you compare it to the screenshots of the app, you can see this is not how it should look like.
That's even though on all Android devices that I've checked, and on all emulators, I've never seen it (even when switching to Hebrew).
What I've tried
I've tried to fix it by using a GridLayout instead, but that wasn't working well (link here).
I've also tried to use a LinearLayout, but considering there might be issues with it, I've used LinearLayoutCompat instead. It works, but it's not recommended to use so many.
Another thing I've tried is to port the RelativeLayout of Android source code, but this gives me a lot of warnings and errors that are quite hard to handle.
Here's the original XML of the layout, BTW (I've removed the irrelevant stuff, to make it shorter) :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="afterDescendants" >
<ImageView
android:id="#+id/appIconImageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:adjustViewBounds="true"
android:src="#android:drawable/sym_def_app_icon" />
<LinearLayout
android:id="#+id/appDetailsContainer"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/appIconImageView"
android:layout_toLeftOf="#+id/overflowView"
android:layout_toRightOf="#+id/appIconImageView"
android:layout_toStartOf="#+id/overflowView"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:text="label" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="description" />
</LinearLayout>
<ImageView
android:id="#+id/overflowView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="#android:drawable/sym_def_app_icon" />
<ImageView
android:id="#+id/isSystemAppImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:src="#android:drawable/sym_def_app_icon" />
</RelativeLayout>
The question
As I use RelativeLayout, how can I port the code from the official source code of Android?
Is there maybe a library that does it?

Android TextView top image not rendering properly on 2.3

When I run my android application in Android version >=4 I got this out put(I didn't tested in android version 3):
When run the same application in android version 2.3 I got a bit different output:
You can see in second screenshot the image for about button is not visible. But when I try run the same application several times on 2.3 some times I got about image visible.Here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/actionbar_with_right_button" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/snooze_button"
android:gravity="center"
android:onClick="showRemainderSnoozeSettings"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/snooze" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/help_button"
android:gravity="center"
android:onClick="showFaq"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/help" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/about_button"
android:gravity="center"
android:onClick="showAbout"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/about" />
</LinearLayout>
</ScrollView>
I didn't understand why this is happening.
Can anyone help me to solve this issue.
Edit :
One more important thing I forgot to mention when I changed android:drawableTop="#drawable/about_button" to android:drawableTop="#drawable/help_button" of about TextView. It worked perfectly. So it can be an issue of my about_button image. So I recreated the about image again and put in all drawable folder. Even after that also I didn't get any +ve result. This issue only in 2.3 or less.
Thanks
May this help you:
Seems like this is a bug with android, where sometimes the first image in the drawable folder doesn't get displayed.....
I had a similar bug - a particular drawable was not being displayed, no matter in what ImageView. So I Added a dummy image called aaaa.png to the drawable folder and problem was solved....

Android UI editor/display bug

While developing an Android application I have stumbled upon a baffling problem. The UI element I am creating is a header bar that has a custom search field. Everything looks wonderful on the Android UI editor but the second I use the emulator or a device it bugs out and compresses the magnifying glass image and clips the edit text. I have tried a number of things including changing the background image of the search area to the custom search field that is currently in the parent LinearLayout. This however results in the search field size growing out of control.
Any suggestions are welcome.
My questions are:
1) How would one fix this problem while maintaining the look of the search area?
2) Why is this problem occurring?
Confirmed on the following devices:
Samsung Galaxy Nexus 4.0.2
Motorola Zoom 4.0.3
Nexus S 2.3.7
This is a screenshot of the UI editor:
This is a screenshot of what it looks like on all devices tested:
The XML used to generate these UI elements:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/title_bar_matte"
android:gravity="center_vertical"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_margin="10dp"
android:layout_weight="1.0"
android:background="#drawable/search_field"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="15dp"
android:src="#drawable/magnifying_glass" />
<EditText
android:id="#+id/campus_map_acitivity_search"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1.0"
android:background="#0FFF"
android:hint="Search"
android:imeOptions="actionSearch"
android:singleLine="true" />
</LinearLayout>
<Button
android:id="#+id/campus_map_activity_goto_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#drawable/button_list" />
<Button
android:id="#+id/campus_map_activity_my_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#drawable/button_location" />
</LinearLayout>
Just figured out the problem. The search background image had the top and left sides set to 9-patch scale. This is all good and well but we had forgotten to set the bottom and right fill areas so that the content would have room to exist.
http://radleymarx.com/blog/simple-guide-to-9-patch/
Remember to set the fill areas!
It turns out the Android UI editor does not handle 9-patch images like the devices. That seems to be a bug to me.

Categories

Resources