Or will I have to incorporate a ScrollView into the TableLayout? Is this even possible? I want to dynamically create any number of rows for a screen, but need the rows to be scrollable.
I've been trying in vain to get this to work using LinearLayout for too long now, and think it's time to move either to TableLayout or RelativeLayout -- any comments on the preferability of one over the other?
You can use table layout within scroll layout then it is possible.
for example,
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
You can use table layout instead of Linear layout..
None of the "list"-style views will automatically do scrolling. LinearLayout, TableLayout, RelativeLayout, none of them do it because (like other people pointed out) it's so easy to wrap them in a ScrollView, it's just functionality that they don't need.
You have to specify a ScrollView for your TableLayout just as below:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:background="#ffffff"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff">
<TableLayout
android:id="#+id/myTableLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:shrinkColumns="1"/>
</RelativeLayout>
</ScrollView>
Related
I'm trying use TableLayout to make a table and is much informations to screen of smartphone, so i need of a Horizontal Scroll, but if i use HorizontalScrollView, the TableLayout and my button of the screen have the background blank, the background simply disappears. I try use ScrollView (vertical) in test and all work fine, so the problem is in HorizontalScrollView in my opinion.
I try to change the width to a number, for example, width:"450 dp" and all resolved, but to approximately "1400 dp" all returned... My table is very large, have approximately 21 columns, so they tableLayout is much higher of "1400 dp".
i'm losing the hope, trying anything and nothing resolved.
somebody help me.
image below:
TableLayout with all working, but with ScrollView vertical, cutting the table without horizontal scroll:
http://s11.postimg.org/k9hg1a79v/Screenshot_2015_02_19_15_43_56.png
TableLayout with HorizontalScrollView, all backgrounds missing, this is the problem, TableLayout, TableRow and button lost the background.
http://s4.postimg.org/iprnwxg65/2015_02_19_15_41_14.png
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/HorizontalScrollView1"
android:layout_width="match_parent"
android:background="#drawable/background_start_screen"
android:layout_height="match_parent"
android:fillViewport="true" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:id="#+id/table"
android:background="#drawable/border"
android:layout_marginTop="5dp"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</TableLayout>
<Button
android:id="#+id/button1"
android:background="#drawable/button_deny_state"
android:layout_marginTop="20dp"
android:textColor="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="fechaTela"
android:text="Fechar" />
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
You have to inflate items to HorizontalScrollView one by one with using adapter. Firstly you have to learn adapter mecanism.
This is an adapter example for custom listView :
http://www.learn2crack.com/2013/10/android-custom-listview-images-text-example.html
This can helps to solve your problem :
https://code.google.com/p/androidbeginner/source/browse/trunk/andriod/src/slieer/com/layout/TableAdapter.java?r=48
Basically, I am making an android widget with views scrolling left to right and right to left, depending on the direction of a user swipe.
Below is my mail.xml. Can someone suggest me how to make a horizontal scroller? When I change this layout it says: Problem loading widget. Please suggest me a solution.
<?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:layout_margin="4dp"
android:background="#drawable/background"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/widget1label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/widget1txt"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
I think HorizontalScrollView is what you're looking for. Simply wrap the element you want to scroll and it should work.
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/heading_title"
/>
<ScrollView
android:id="#+id/layout"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:scrollbars="horizontal|vertical"
android:layout_width="fill_parent"
android:layout_marginTop="5dip"
android:scrollbarStyle="outsideInset"
android:fillViewport="true">
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_height="fill_parent"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_marginTop="5dip">
............Place all your layouts, views, such as linear layouts, table layouts, etc, that are needed for your app. Note that the TextView for heading/title (see above) will be outside the scrollview, so it will always stay visible at the top. Remove this if not needed, or add there more views as needed .............
</HorizontalScrollView>
</ScrollView>
So the answer is:Creating the App Widget layout is simple if you're familiar with Layouts. However, you must be aware that App Widget layouts are based on RemoteViews, which do not support every kind of layout or view widget.
A RemoteViews object (and, consequently, an App Widget) can support the following layout classes:
FrameLayout
LinearLayout
RelativeLayout
GridLayout
And the following widget classes:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper
i am developing an android app where i am showing day wise channel schedule (multiple rows).
now in this i have to provide both vertical and horizontal scrollability.
vertical scrollability will be normal , but horizontal scrollability should be synchronized
that is when user scrolls horizontally all other rows should also be scrolled in a sync.
i tried using table layout but its not going good with my requirement and i have also tried TwoWayView but i am not able to sync the horizontal scrolling.
i would like to know i anyone have faced/solved the similar situation.
Any leads on this is highly appreciated.
xml for vertical and horizontal Scrolling :-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/vertical_scroll_view2">
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/horizontal_scroll_view2">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="910dp"
android:id="#+id/scheduleContainer"
android:orientation="vertical"
/>
</HorizontalScrollView>
</ScrollView>
.....
xml for TwoWayView:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/weekday"
android:layout_height="fill_parent"
android:layout_width="40dp"
android:textSize="12dp"
android:textStyle="bold" />
<com.mobiotics.tvb_stb.utilityclasses.TwoWayView
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/hlist"
style="#style/TwoWayView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="#id/weekday"
android:scrollbars="none"
android:drawSelectorOnTop="false"
tools:context="com.mobiotics.tvb_stb.activity.HomeScreenActivity" />
</RelativeLayout>
i am adding twoway list to linear layout .
If you can have a ListView, I would start there. Just drop the ListView into a HorizontalScrollView. Make sure to set the width of the HorizontalScrollView to wrap_content. I noticed you have it set to fill_parent.
I want to assign layout weights to several items within a LinearLayout inside of a ScrollView. However, the ScrollView ignores the LinearLayout weightSum.
My goal is to divide the layout with weights of 2, 1, 1 (for a total sum of 4), but this does not work properly inside of a ScrollView.
How can I solve this layout problem?
main.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="4">
<LinearLayout android:id="#+id/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="2"
android:background="#FFFFFF" />
<LinearLayout android:id="#+id/logo1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="1"
android:background="#000000" />
<LinearLayout android:id="#+id/logobutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
android:background="#4B4B4B" />
</LinearLayout>
</ScrollView>
I have faced this problem before. Just use android:fillViewport="true" in your ScrollView and it will fill up the screen.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
This won't work as you have done it. The child view of a ScrollView should be set to wrap_content. If you set it to fill_parent, it will fill the area of the ScrollView and never scroll, because it won't be larger than the ScrollView.
The idea of layout_weight is to fill a specific area proportionately.
You should set all of the child LinearLayouts layout_height to either wrap_content or a specific size (in dp) and the parent LinearLayout layout_height to wrap_content
As said you need to remove the additional
xmlns:android="http://schemas.android.com/apk/res/android"
if it's not the root (first) element of the layout.
just put this in your scroll view:
android:fillViewport="true"
In my experience, fillviewport=true works bit strange.
I solved this problem by wrapping LinearLayout with another Layout like FrameLayout.
I hope this helps.
Add below line in your ScrollView it will be work fine.
Only single child must be there for ScrollView
android:fillViewport="true"
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