0

Ok, after trying any solution I found I decided to put my code in here for help. I get HTML from JSON and I place it in a TextView to show it.

This is it:

hoursTextView.setText(Html.fromHtml(hours));
                                hoursTextView.setVisibility(View.VISIBLE);

My problem is, that whenever the content above this TextView takes alot of height, I see only cutted top letters of this TextView and I can't scroll down!

This is my Layout XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    >

    <ProgressBar
        android:id="@+id/loadData"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:layout_centerInParent="true"
        />

    <ImageView
        android:id="@+id/coverImg"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:scaleType="fitCenter"
        android:adjustViewBounds="true"
        android:layout_marginBottom="5dp"
        />

    <TextView
        android:id="@+id/fbAbout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/coverImg"
        android:gravity="center"
        />

    <View
        android:id="@+id/seperator"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#eeeeee"
        android:layout_below="@+id/fbAbout"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        />

    <LinearLayout
        android:id="@+id/buttons"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/seperator"
        android:layout_marginStart="5dp"
        android:layout_marginEnd="5dp"
        >

    <TextView
        android:id="@+id/type"
        android:layout_width="0dp"
        android:layout_height="70dp"
        android:background="@drawable/circle_text"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="10dp"
        android:drawableTop="@drawable/beer"
        android:drawablePadding="5dp"
        android:text="TYPE"
        android:layout_weight="1"
        />

    <TextView
    android:id="@+id/age"
    android:layout_width="0dp"
        android:layout_height="70dp"
    android:background="@drawable/circle_text"
    android:textAlignment="center"
    android:gravity="center"
    android:padding="10dp"
    android:drawableTop="@drawable/age_big"
    android:drawablePadding="5dp"
        android:layout_marginStart="10dp"
        android:text="AGE"
        android:layout_weight="1"
    />

    <Button
        android:id="@+id/callToPlace"
        android:layout_width="0dp"
        android:layout_height="70dp"
        android:background="@drawable/circle_text"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="10dp"
        android:drawableTop="@drawable/ic_call_black_24dp"
        android:drawablePadding="5dp"
        android:layout_marginStart="10dp"
        android:text="CALL"
        android:layout_weight="1"
        />

    <Button
        android:id="@+id/nav"
        android:layout_width="0dp"
        android:layout_height="70dp"
        android:background="@drawable/circle_text"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="10dp"
        android:drawableTop="@drawable/navigate"
        android:drawablePadding="5dp"
        android:layout_marginStart="10dp"
        android:text="navigate"
        android:layout_weight="1"
        />

    </LinearLayout>


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="HOURS"
        android:id="@+id/hoursTitle"
        android:layout_below="@+id/buttons"
        android:layout_centerHorizontal="true"
        android:visibility="gone"
        android:layout_marginTop="10dp"
        />
<!--This is the TextView which is cut -->
    <TextView
        android:id="@+id/hours"
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/hoursTitle"
        android:visibility="gone"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        />

</RelativeLayout>

The last TextView, with the ID of hours, is being cut on the bottom of the screen. Hope someone can help me with this, thanks!

  • 1
    add a (ScrollView ) above the RelativeLayout. that will enable you to scroll when content is larger than the physical display -- http://stackoverflow.com/questions/6674341/how-to-use-scrollview-in-android – Tasos Dec 28 '15 at 09:20
  • if You want to scroll down, You have to use a scroll layout like scrollView. This is definetely a overweight layout for a RelativeLayout parent.... – Opiatefuchs Dec 28 '15 at 09:20

2 Answers2

0

Add the scroll view

<ScrollView
                android:layout_width="match_parent"
                android:layout_height="150dp" >
    <!--Just assume it whatever your height is-->
            <TextView
                android:id="@+id/hours"
                android:layout_marginTop="5dp"
                android:layout_width="wrap_content"
                android:layout_height="150dp"
                android:layout_below="@+id/hoursTitle"
                android:visibility="gone"
                android:layout_centerHorizontal="true"
                android:gravity="center"
                />
             </ScrollView>
asad.qazi
  • 2,449
  • 3
  • 23
  • 35
0

You can use ScrollView for full screen.

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:layout_below="@+id/output">
   <ProgressBar
        android:id="@+id/loadData"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:layout_centerInParent="true"
        />

    <ImageView
        android:id="@+id/coverImg"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:scaleType="fitCenter"
        android:adjustViewBounds="true"
        android:layout_marginBottom="5dp"
        />

    <TextView
        android:id="@+id/fbAbout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/coverImg"
        android:gravity="center"
        />

    <View
        android:id="@+id/seperator"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#eeeeee"
        android:layout_below="@+id/fbAbout"
        android:layout_marginBottom="5dp"
        android:layout_marginTop="5dp"
        />

    <LinearLayout
        android:id="@+id/buttons"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/seperator"
        android:layout_marginStart="5dp"
        android:layout_marginEnd="5dp"
        >

    <TextView
        android:id="@+id/type"
        android:layout_width="0dp"
        android:layout_height="70dp"
        android:background="@drawable/circle_text"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="10dp"
        android:drawableTop="@drawable/beer"
        android:drawablePadding="5dp"
        android:text="TYPE"
        android:layout_weight="1"
        />

    <TextView
    android:id="@+id/age"
    android:layout_width="0dp"
        android:layout_height="70dp"
    android:background="@drawable/circle_text"
    android:textAlignment="center"
    android:gravity="center"
    android:padding="10dp"
    android:drawableTop="@drawable/age_big"
    android:drawablePadding="5dp"
        android:layout_marginStart="10dp"
        android:text="AGE"
        android:layout_weight="1"
    />

    <Button
        android:id="@+id/callToPlace"
        android:layout_width="0dp"
        android:layout_height="70dp"
        android:background="@drawable/circle_text"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="10dp"
        android:drawableTop="@drawable/ic_call_black_24dp"
        android:drawablePadding="5dp"
        android:layout_marginStart="10dp"
        android:text="CALL"
        android:layout_weight="1"
        />

    <Button
        android:id="@+id/nav"
        android:layout_width="0dp"
        android:layout_height="70dp"
        android:background="@drawable/circle_text"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="10dp"
        android:drawableTop="@drawable/navigate"
        android:drawablePadding="5dp"
        android:layout_marginStart="10dp"
        android:text="navigate"
        android:layout_weight="1"
        />

    </LinearLayout>


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="HOURS"
        android:id="@+id/hoursTitle"
        android:layout_below="@+id/buttons"
        android:layout_centerHorizontal="true"
        android:visibility="gone"
        android:layout_marginTop="10dp"
        />
<!--This is the TextView which is cut -->
    <TextView
        android:id="@+id/hours"
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/hoursTitle"
        android:visibility="gone"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        />
     </ScrollView>

Another Example:

<?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="wrap_content" >

    <LinearLayout

        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 1" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 2" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 3" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 4" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 5" />

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <RadioButton
            android:id="@+id/radioButton2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton 1" />

        <RadioButton
            android:id="@+id/radioButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="RadioButton 2" />

        <ToggleButton
            android:id="@+id/toggleButton1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="ToggleButton" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 6" />

        <SeekBar
            android:id="@+id/seekBar1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <Button
            android:id="@+id/button3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button 7" />

        <Button
            android:id="@+id/button4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button 8" />

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="CheckBox" />

        <Button
            android:id="@+id/button2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button 9" />

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button 10" />

        <Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Button 11" />
    </LinearLayout>

</ScrollView>
Md Rahman
  • 1,812
  • 1
  • 14
  • 15