I have a crash (Application Stopped Unexpectedly) problem with this main.xml is a "HelloWorld" type project (while testing and learning features I need for my app) :
I isolated the ImageButton as an issue, but I can't isolate any of the parameters...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageButton android:id="#+id/picture"
android:layout_width="240dip"
android:layout_height="180dip"
android:layout_gravity="center_horizontal"
android:src="#drawable/icon"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:clickable="true"
android:scaleType="fitCenter" />
</LinearLayout>
icon.png exists in my resources...
I can see the preview in the Layout tab, even though the image is not centered on the button, but I read that it was normal.
The code below works fine (as a regular Button). I can also do the same as an ImageView.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button android:id="#+id/picture"
android:layout_width="240dip"
android:layout_height="180dip"
android:layout_gravity="center_horizontal" />
</LinearLayout>
I use Eclipse and the AVD, and all my learning is done on 2.1 (SDK level 7).
I can't test the app on an actual device yet as I don't have it yet.
Thanks in advance !
Oh bother !!
It seems that it was a java error in my MyApp.java, when I was trying to declare the event for the button. Case closed. Sorry.
Related
I’ve created a widget with the wizard. Then I’ve customized the layout.
I tried to run but all I got is the error view of the widget “Problem loading widget”.
Checking the log I found this error:
W/AppWidgetHostView: updateAppWidget couldn't find any view, using error view
It says that the system could not find any view, but my layout is defined in res/layout/ and declared in widget info xml file.
What am I missing? Here is the project on GitHub.
You're not doing much that's wrong. The entire app widget is setup correctly. It is purely a layout issue. It doesn't seem to be happy with the complexity of the playback_widget.xml file. I changed the file to the following:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/playback_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/poster_imageview"
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/ic_headset_mic_light_black_140dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/title_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textAlignment="center"
android:textColor="#color/primaryTextColor"
android:textSize="16sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="#dimen/default_text_padding">
<ImageView
android:id="#+id/player_previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_toLeftOf="#+id/player_play_pause"
android:src="#drawable/ic_skip_previous_white_32dp" />
<ImageView
android:id="#+id/player_play_pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_play_arrow_white_40dp" />
<ImageView
android:id="#+id/player_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:layout_toRightOf="#id/player_play_pause"
android:src="#drawable/ic_skip_next_white_32dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
The widget views appear fine now. I realise this probably isn't the exact layout that you're after, but you'll just have to play around with it until you find something that it is happy with.
Home screen widgets can be a bit tricky because you have a more limited set of views and less flexibility in terms of the layout.
Also I haven't checked but I'm not sure that the following view is allowed in homescreen widgets:
<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="?colorAccent" />
Also if you have trouble getting that error to go away. Destroy the home screen widget and restart the phone. They sometimes get into a dorked up state during development.
But in any event your project is working fine for me after the playback_widget.xml change. Android 8.0.
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?
I am tasked with determining why a 5 year old app (worked on by a few teams) that supports API 8 through API 19 only has this particular issue with API 15.
The issue is the app is not displaying any data in it's 2 ListViews.
A few details:
There are no errors reported in logcat. I run the app on both API 15 and API 16 emulators and their logcats look almost identical.
Calling listview.getAdapter().getCount() does return an expected value greater than 0.
(UPDATE)
3. listview.getItem() and listview.getView() are NOT being called.
listview.getVisibility() does return View.VISIBLE
Oddly, backing out of the app and restarting it, allows the data to display(!)
I have searched for several days now on what could be the cause of this working fine on API 16, as in "what was fixed" between 15 and 16, but nothing that makes sense showed up. I have been shy to ask here due to this making me sound crazy :-)
I'm hoping someone has encountered this with 4.0.3 and can give me my next path to solve this. Posting code will be very difficult, but any reasonable requests will be happily complied with. Thanks!
No one is going to believe me ;-), but the fix was to remove:
android:animateLayoutChanges="true"
...from a LinearLayout in the app's main layout file (which contains a support ViewPager and whose root was a TabHost, not that those necessarily matter).
I couldn't believe this myself, so I replaced and removed it a couple of times and it would alternate between "breaking" and "working".
I have no idea why this worked, but I've listed the .xml file here
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/aim_light_grey" >
<!-- android:animateLayoutChanges below was the problem!!! -->
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:animateLayoutChanges="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/no_network_indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/warn_gray" />
<TextView
android:id="#+id/tv_not_connected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="#color/light_grey"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:text="#string/not_connected"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="44dip"
android:layout_weight="0"
android:background="#color/blue"
android:visibility="gone" >
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="#string/image_logo_accessibility_description"
android:src="#drawable/action_1" />
<TabWidget
android:id="#android:id/tabs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
</LinearLayout>
</TabHost>
I am a newbie to android app development, i am using the ADT with eclipse.
I wrapped all the view components in a scrollbar but when i use the emulator preview i cannot see the scrollbar. The target is a 7inch WSVGA (Tablet).
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/imageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/test_image_date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="#+id/Clouds"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/test_image"
/>
<TextView
android:id="#+id/imageDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/test_image_description"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</ScrollView>
No errors have been generated.
Cheers
Ciaran
The scrollview will only be visible if you have enough content that would not fit on the entire screen. Seeing your xml it is possible that you don't have that much of content in the layout
So ran this activity on a Samsung T3 8 inch tablet and the scroll worked fine, couldn't seem to get it on the emulator with a similar simulated device.
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....