开发者

Android app scrolling

I have created a simple app with a XML-based layout. The ImageView src and the TextView texts are filled with content onCreate after receiving data from a http request. The problem is that the scrolling of the phone is not working when the GUI is rendered. At all. Can someone with a little more experience please assist me? Thanks in advance! /Jesper

Main.xml:

<?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"
    android:padding="30px"
    >

<ImageView  xmlns:android="http://schemas.android.com/apk/res/android"   
  android:id="@+id/image1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  />
  <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:paddingBottom="20px"
    >
    <TableRow>
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Players"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/players1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Bad Beat Jackpot"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/bbj1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hand #"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/hand1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>
</TableLayout>

<ImageView  xmlns:android="http://schemas.android.com/apk/res/android"   
  android:id="@+id/image2"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  />
  <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:paddingBottom="20px"
    >
    <TableRow>
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Players"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/players2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Bad Beat Jackpot"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/bbj2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hand #"
          />
          <TextView xmlns:android="ht开发者_Go百科tp://schemas.android.com/apk/res/android"   
          android:id="@+id/hand2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="2"
          />
    </TableRow>
</TableLayout>  

<ImageView  xmlns:android="http://schemas.android.com/apk/res/android"   
  android:id="@+id/image3"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  />
  <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:paddingBottom="20px"
    >
    <TableRow>
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Players"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/players3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Bad Beat Jackpot"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/bbj3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="3"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hand #"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/hand3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="4"
          />
    </TableRow>
</TableLayout>  

<ImageView  xmlns:android="http://schemas.android.com/apk/res/android"   
  android:id="@+id/image4"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  />
  <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="1"
    android:paddingBottom="20px"
    >
    <TableRow>
        <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Players"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/players4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Bad Beat Jackpot"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/bbj4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>

    <TableRow>
       <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hand #"
          />
          <TextView xmlns:android="http://schemas.android.com/apk/res/android"   
          android:id="@+id/hand4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:gravity="right"
          android:text="0"
          />
    </TableRow>
</TableLayout>  
</LinearLayout>


if i have understand your question,have you tried to include all your xml into a parent <ScrollView>??

EDIT:

something like:

< ScrollView
     xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
          android:background="@drawable/back"
    >
    <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
    //more xml tags....

    </RelativeLayout>
    </ScrollView>


Putting everything in <scrollview> tags worked for me. Make sure to have it fill the viewport using android:fillViewport="true"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜