I'm trying to create an achartengine chart within a scrollview but it won't display! It just shows a black screen, but doesn't crash or anything. The thing is if I just change my tag to the chart displays just fine. And in my Java code I do have renderer.setInScroll(true); for the charts renderer. Is this an issue with my xml?
Here is my xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/trendchart"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</ScrollView>
(Currently the only thing in the ScrollView is the chart I plan to add more elements to make scrolling necessary, I just want it to display first)
Also I have tried to display it both with and without the wrapping linearlayout and it is the same result.
Under the scrollview you have to insert
android:fillViewport="true"
You will also have to do the following call, otherwise there will be display issues:
renderer.setInScroll(true);
Other solution is to give a size for your LinearLayout #+id/trendchart:
for example:
<LinearLayout
android:id="#+id/trendchart"
android:layout_width="fill_parent"
android:layout_height="180dp"
android:orientation="vertical" />
</LinearLayout>
works fine for me.
I've tried the accepted answers but none of them work for me. I solved my problem by adding
chartView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 500));
But don't use
chartView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
because for some reason it still not displaying the chart. Hope that will help someone
Related
Does anyone know how to show multiple files in one XML file? This is like having a pane with two ListViews, one on the left and one on the right. I tried to set one ListView's android:gravity to the left and the other to the right. I have also tried using LinearLayout and creating two RelativeLayouts on it but it still doesn't do anything.
Any links, comments, suggestions or sample codes are much appreciated...
Use a relative layout. Then have the left one align to the parent's left edge, and the right one layout_toRightOf the left list.
Simple side by side layout with each view taking up half the screen
<?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="horizontal" >
<ListView
android:id="#+id/list1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1" />
<ListView
android:id="#+id/list2"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:fadeScrollbars="false" >
<Scrollview ...
i want to show the scrollbar always (android:fadeScrollbars="false")! I have also EditTexts on my screen, too. That is why I put (android:focusableInTouchMode="true" and android:focusable="true"). If i put this last 2 codes my scrollbar going to fade out, why? Do you have a solution?
please this in place of that one.
Achieved the desired result here and added in manifest for each activity
android:windowSoftInputMode="stateHidden"
I am putting more than 15 buttons in one .xml file. But it seem only to be displaying the top 9 of them ? Why aren't the other buttons showed or can't I scroll down to see them?
I am using a LinearLayout with tags.
Are you using a LinearLayout perhaps to contain the buttons? Or any other layout that's not contained in a ScrollView? Good chance your buttons are being drawn, they are just outside your screen.
Wrap your layout in a ScrollView like so:
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:scrollbars="none" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<!-- your buttons here -->
</LinearLayout>
</ScrollView>
This makes your layout scrollable, so you will be able to just scroll down and see your buttons.
Did you use this?
android:orientation="vertical"
Please post your code,
Are you wrapping everything is ScrollView?:
<ScrollView android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ScrollView>
More info http://developer.android.com/reference/android/widget/ScrollView.html
I have a problem with my ScrollView. It has an ImageView inside it. The imageView holds an image which is 480 * 3000 px. So It needs to be in a ScrollView so the user will have the ability to scroll down.
The problem is: when I test the application, the ScrollView does not wrap to the image hight. There is a black space under the image which is strange for me.
This is my XML code. I look forward for your opinion
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/image"
android:src="#drawable/image01"
android:scaleType="fitStart" />
</ScrollView>
</RelativeLayout>
Update:
This is how my image looks like with #ruhalde code. I can't take a screenshoot since it is big and you'll not see the whole picture so I draw it.
Rewrite your layout. Make the ScrollView the outer most element. Take a look at this good tutorial for more information: http://mobiforge.com/designing/story/understanding-user-interface-android-part-1-layouts
Use a LinearLayout instead of RelativeLayout which is deprecated by now. Set fillViewPort=true in your ScrollView XML or programatically if you want with setFillViewPort(true).
Put imageview inside a LinearLayout and that inside ScrollView, your XML should look like this:
LinearLayout
---ScrollView
----LinearLayout
------ImageView
Check out my XML here working good with a 800 x 4000 pixels image, perfectly scrolling vertical:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView android:id="#+id/scrollView1"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:id="#+id/linearLayout1"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:id="#+id/mapa" android:layout_height="wrap_content"
android:layout_width="wrap_content"></ImageView>
</LinearLayout>
</ScrollView>
</LinearLayout>
To those who might be interested:
My problem was with the image I'm using, not how I organize my layouts. Thanks.
I believe you should use scrollView tag before your layout tag
I am having an issue that make me crazy
I have a listview with WebView inside. So I created a custom listview.
The WebView forbid me to click so I created a webviewclicklistener.
My problem was that when I display some images, my webviews are "shaking" as if it wants to load the image a thousand times.
In fact I discovered that the height size of some elements change like every seconds, that give a feeling of shake.
The only way I found to fix it is to give a layout:height value for my listview.
My new problem is that when I put for exemple 600dip, I have a scrollbar, but I can't look at the end of my listviews.
If I put like 1000dip, I don't have scroll bar and I can't see the end of my list neither.
Here is my layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="#drawable/woodbackground"
android:layout_weight="1">
<TextView android:background="#android:color/transparent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:hint="Question" android:textSize="30px"></TextView>
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<WebView android:id="#+id/wvplquestion" android:layout_height="wrap_content"
android:layout_width="fill_parent"></WebView>
</ScrollView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#android:color/transparent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight="1">
<TextView android:background="#android:color/transparent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:hint="Select Answer" android:textSize="30px"></TextView>
<ListView android:id="#+id/lvquestion" android:layout_width="fill_parent"
android:layout_height="600dip" android:prompt="#string/selectp" />
</LinearLayout>
And my custom listview layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:padding="3dip">
<WebView android:id="#+id/weblistview" android:layout_width="fill_parent"
android:layout_height="wrap_content"></WebView>
Thanks for your help
maybe you can try to change your listview layout height. Instead of wrap content, put a fixed height. I don't know if it will be working, but you can try it. I'd a problem similar to yours and I solved it like this.
I hope it will work. Good luck ;)
Seems it mostly happens when several webviews contained into one scrollview. Seems at least first webviews should have fixed height.